AnsweredAssumed Answered

How to build mixed C and C++ project in CodeWarror

Question asked by David Sclarsky on Jan 3, 2020
Latest reply on Jan 7, 2020 by David Sclarsky


I have an ongoing GCC LINUX project with dozens of source files all written in C.

The project builds with CodeWarrior for our QorIQ processor board.

I would like to introduce some isolated C++ code to the project, but minimize the changes required to the existing source code.

I know how to write mixed C and C++ code, using extern "C", etc, so that's not a problem.

My problem is getting CodeWarrior to compile the project correctly.

To simplify, I created a brand new C++ project, which gave me main.cpp.

CodeWarrior chooses g++ to build main.cpp.

I then added one C source file, called funcs.c.

I was hoping that CodeWarrior would choose gcc for this new file, but it chose g++ instead.

I tried adding the C Compiler via the tool chain editor (ignoring the "tool conflict" error), but this didn't help.


Does anyone know how I can coerce CodeWarrior to use the C compiler for files with .c extension and continue to use the C++ compiler for files with .cpp extension?