I'm trying to compile C and C++ sources together using GCC.
gcc -std=c++0x test.cpp -std=c99 test.c -lstdc++
Now, this works fine, except that I get two warnings.
cc1plus: warning: command line option "-std=c99" is valid for C/ObjC but not for C++ cc1: warning: command line option "-std=c++0x" is valid for C++/ObjC++ but not for C
Therefore I can't use -Werror
with this setup. Can these warnings be suppressed somehow?
Talking about main.o "calling functions in" module.o is perfectly fine, but an .o file is not a source file, it's a compiled object file. If "put my source code in files with extension .o " actually meant "compile my source code into files with extension .o " then the situation would make a whole lot more sense.
gcc is used to compile C program. g++ can compile any . c or . cpp files but they will be treated as C++ files only.
if anyone else is wondering the best way to do this in Android, it's this:
LOCAL_CFLAGS := -Werror LOCAL_CONLYFLAGS := -std=gnu99 LOCAL_CPPFLAGS := -std=c++0x
Compile the files separately, link with g++
gcc -c -std=c99 -o file1.o file1.c g++ -c -std=c++0x -o file2.o file2.cpp g++ -o myapp file1.o file2.o
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With