Hello,
I have a base project that uses C99. (compiler option --c99)
Basically c99 was used so that an aggregate type could be initialized with non-constant data as such:
#define WRITE_OP_CODE (34) void test_fn(unsigned char param1, unsigned char param2) { unsigned char writebuff[3] = {WRITE_OP_CODE, param1, param2}; // no error on one compiler // and a "expression must have a constant value" error on another ... }
The problem is I am now mixing in some c++ (third part library) and I get all sort of errors for the C linkage (extern "c")
Does anyone have a suggestion as to how to mix C99 and C++ with various extern c linkage statements?
Hi Scott,
Thanks for the information. I don't think this is the problem though. I think it's more of a setup problem.
My project compiles as expected without any errors. It is a mix of C (*.c) and C++ (*.cpp). When I add the "--c99" flag to the compiler arguments it seems as though it is trying to compile the C++ source as C99.
For example I get this type of error: error: #20: identifier "class" is undefined
How do I set up the project options such that *.c files are compiled with "--c99" and *.cpp files are compiled as C++?
Thanks
M
Ah, I see. I don't think there is a way to use the same options and get C99 with .c files and C++ with .cpp files. You might find using C++ (--cpp) for your .c files gives you what you want.
How about opening the options for the individual C files and manually give the -c99 option instead of giving it globally for the project?
This really seems to be a Keil bug to be officially reported. A project should be able to mix C and C++ without having the language-specific options fight each other.