views:

98

answers:

2

I'm using the VxWorks MIPS compiler and I have some third party source that needs to be compiled as c++ but all the extensions are .c. There must be a switch I can pass into the compiler in this case to force C++ compilation but I can't find it.

Any suggestions?

A: 

One trick is to create a meta file that includes all the 3rd party source and rename it .cpp/.cc. Something like:

find 3rd_party -type f -name '*\.c' | awk '{print "#include \"" $0 "\""}' > build_3rd_party.cc

You'll have to make sure all the -I's line up and mess with the compile flags they want. This will also speed things up a bit if there are piles of subdirectories to recurse through.

Failing that, pass a new CC env var to make for the 3rd party stuff which really points to the cpp compiler.

tim
+2  A: 

Is the VxWorks MIPS compiler just gcc with a different name? If so you might be able to give it the flag -x c++ to explicitly specify the language rather than letting the compiler choose a default based on the file name suffix.

Dan