6 years, 2 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...

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

1 Answer

6 years, 1 month 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.