3

I have a project containing both C++ and C files which I am compiling from the command line with Emscripten using this command:

emcc -s WASM=1 -o output.html -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'Pointer_stringify']" -s ASSERTIONS=1 -O1 -O2 -O3 -std=c++11 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1  file1.cpp file2.c

I need to use c++11 for this to work but because some of the files are in C it gives this error:

error: invalid argument '-std=c++11' not allowed with 'C/ObjC'

Is there some way I can tell the compiler to only use c++11 for the C++ files but not the C files?

J. Douglas
  • 67
  • 2
  • 6

1 Answers1

-1

Yes, you can use the environment variable CXXFLAGS to do so.

In practice, in your case, you should split the command line in two: one for C++ files, one for C files. This is what we usually find in Makefiles.

Victor Paléologue
  • 2,025
  • 1
  • 17
  • 27