Author Topic: Stupid Noob Question  (Read 4693 times)

Offline mathguy

  • Multiple posting newcomer
  • *
  • Posts: 12
Stupid Noob Question
« 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.

zabzonk

  • Guest
Re: Stupid Noob Question
« Reply #1 on: November 16, 2011, 06:03:10 pm »
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.

Offline mathguy

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Stupid Noob Question
« Reply #2 on: November 16, 2011, 06:13:50 pm »
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?

zabzonk

  • Guest
Re: Stupid Noob Question
« Reply #3 on: November 16, 2011, 06:18:57 pm »
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.

Offline mathguy

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Stupid Noob Question
« Reply #4 on: November 16, 2011, 06:25:37 pm »
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.

Offline mathguy

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Stupid Noob Question
« Reply #5 on: November 16, 2011, 06:31:04 pm »
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

zabzonk

  • Guest
Re: Stupid Noob Question
« Reply #6 on: November 16, 2011, 06:36:50 pm »
You need to ask questions about stuff like that elsewhere, I'm afraid.

Offline mathguy

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Stupid Noob Question
« Reply #7 on: November 16, 2011, 06:53:01 pm »
Will do.  Thank you for your time and attention.  I appreciate it!