Skip to content

Hash sign in multiline string causes "Unknown preprocessor directive" error #19002

Closed

Description

@bbrk24

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.32 (eab98adf462c39f3c31d348331c4830bcaa36949)
clang version 17.0.0 (https://github.com/llvm/llvm-project df82394e7a2d06506718cafa347bf7827c79fc4f)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\[...]\emsdk\upstream\bin

Failing command line in full:

emcc ./*.cpp --post-js post.js 

Where post.js is:

const foo = `
#bar`;

Note that this does not happen if the hash sign is not the first (non-whitespace) character on the line. So, this would not trigger the error:

const foo = '\n#bar';

Full link command and output with -v appended:
Full output is over 26kB, so I can't attach it here. The wasm file is successfully generated, however. Without -v, the output is (with some paths redacted):

Internal compiler error in src/compiler.js!
Please create a bug report at https://github.com/emscripten-core/emscripten/issues/
with a log of the build and the input files used to run. Exception message: "Error: C:\[...]\[...]\post.js:2: Unknown preprocessor directive #bar`;
    at preprocess (C:\[...]\emsdk\upstream\emscripten\src\parseTools.js:137:17)
    at includeFile (C:\[...]\emsdk\upstream\emscripten\src\jsifier.js:456:25)
    at finalCombiner (C:\[...]\emsdk\upstream\emscripten\src\jsifier.js:528:7)
    at runJSify (C:\[...]\emsdk\upstream\emscripten\src\jsifier.js:552:3)
    at Object.<anonymous> (C:\[...]\emsdk\upstream\emscripten\src\compiler.js:97:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
emcc: error: 'C:/[...]/emsdk/node/14.18.2_64bit/bin/node.exe C:\[...]\emsdk\upstream\emscripten\src\compiler.js 
C:\[...]\AppData\Local\Temp\tmppyhfuv98.json' failed (returned 1)

Activity

  1. sbc100 commented on Mar 19, 2023

    @sbc100
    Collaborator

    I believe this is a duplicate of #18609.

  2. bbrk24 commented on Mar 19, 2023

    @bbrk24
    Author

    It does seem to be the same general issue, but they could be considered distinct: that one found it in a block comment, while I encountered it in a multiline string.

  3. added a commit that references this issue on Mar 19, 2023
    3f293fa
  4. added a commit that references this issue on Mar 20, 2023
    b2dbf78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions