Let_Me_Be Let_Me_Be - 1 year ago 84
C++ Question

Compiling C and C++ files together using GCC

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
with this setup. Can these warnings be suppressed somehow?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download