Code::Blocks Forums
User forums => Help => Topic started by: mathguy on November 16, 2011, 05:58:57 pm
-
I'm in the process of trying CodeBlocks for the very first time. I know this question is beyond stupid but I can't seem to find the answer to it. I have a project set up and am getting an error on build that I believe is generated because CodeBlocks is compiling as if the code is C++ but it is C code. How do I set the compiler (I just have the GCC compiler installed) to build as C code?
Thank you for your help.
-
From the CB opening screen, choose "Create new project", then "console application", then select "C" (and not "C++") from the language options. This will create a project with a main.c file which will compile as C code. When adding further files to the project, make sure they have a .c extension and not a .cpp one.
-
Neil,
Thank you for the quick reply. I am trying to build a DLL. Should I just ignore that selection and still pick Console application? Or is there a way to select the DLL and still set it to C compile?
-
It looks like the DLL wizard does not have the language option. You just need to rename the file(s) manually to have the .c extension rather than .cpp, and then add the newly named files to the project.
-
The files do have a .c extension. Maybe the error is not a C++ error. But, I've had this exact same code compile in other compilers with no problem. It's puking on declarations of extern structs.
-
Okay....my bad. Not a C++ error. I tried the Console C setup and I still get the error. This is the error and I don't know why I'm getting it. Like I said, this compiles successfully elsewhere.
error: a storage class can only be specified for objects and functions
-
You need to ask questions about stuff like that elsewhere, I'm afraid.
-
Will do. Thank you for your time and attention. I appreciate it!