Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 5 months ago.
New c files ignored until there are renamed with cpp as extension
Hello,
Sometimes i add manually c source files to my project. If i compile, functions still undefined for the rest of my project. If I rename theses new files with cpp as extension it works...
1 Answer
9 years, 5 months ago.
How are you declaring the functions in the C files?
The reason being that C++ converts the names into decorated names which include the parameters to allow for over loading where as C doesn't. This means you have marked the declarations of the names in the C files as extern "C" which stops this name conversion happening and means that you can link with C code.
Can you further explain your exact problem? You do need to take into account that .c files are really compiled in C, while .cpp files are compiled in C++. But it should be no problem to compile C files.
posted by Erik - 18 Jul 2015