Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: spike351 on December 12, 2010, 07:36:12 am
-
I am a newbie here and just learning about Code::Blocks using MinGW. I can't find anything in the forum archives that address this, so maybe it is just me.
I have a library of standard ANSI C functions I want to include in a wxWidgets project.
I created a demo wxWidgets project called Test. It contains the files TestApp.cpp and TestMain.cpp (plus associated .h files). It builds without error and runs fine.
If I go to File|New|File... and add an empty file called abc.c and try to rebuild the project I get dozens of errors. Adding an empty file called abc.cpp, however, builds as usual.
I can include the code in a cpp file with appropriate extern wrappers (or even just as straight C code allowing it to be compiled as C++) and that gets around the problem, but I don't see why I have to rename the files from .c to .cpp. Why can't I just include a straight C file?
Am I doing something stupid here or is there a config option I have missed? How can I include a C file in a C++ project?
Thanks for any help.
-
If you use the wizard-created wxWidgets project, you have to remove -include wx_pch.h from "Project -> Build options -> Compiler settings -> Other options" and make sure to use #include "wx_pch.h" directly in the cpp-files that use precompiled headers (should be already there, so it might be important for newly created files only).
-
thank you very much for that information Jens. Very much appreciated.