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?
See also this article:
http://www.keil.com/support/docs/3223.htm
1) use extern "C" instead of extern "c". You may have it right in your code, but the 1st post had it wrong.
2) Most likely you have the word class in a .h file. If you include a .h file in a .c file that has c++ syntax, you will get the error you indicate. This is not an issue of a .cpp file being compiled as a .c file, it is a .c file including c++ syntax that is being compiled as a .c file (the default) and generating an error when it sees c++ syntax.
If you think it is a tool issue, you need to provide more details. I mix C and C++ all the time, and setting the --c99 flag does not change anything (compiles and links to the identical executable code)
This is really not yet looking even a little bit like a tool issue. If you want help, post more details of the errors and the files being compiled at the time of the error. Any small sections of code just before and just after the error might help. My guess is the .h file with C++ code in it being included in the .c file is your issue. Then maybe an issue with getting your extern "C" correct.