Author Topic: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?  (Read 6037 times)

Offline Mountaingod

  • Multiple posting newcomer
  • *
  • Posts: 11
Or to put it another way, how does Code::Blocks choose between them when compiling?

I have the GNU GCC Compiler selected as default, but both the above .exe s are listed under Compiler & Debugger Settings > Toolchain Executables .

I'm writing 'pure C' code, which both gcc and g++ can compile. I want to be sure gcc gets used however, so that errors are thrown should any non-C (i.e. C++) creep in.

Does it detect the language automatically - by file extension, parsing, etc. - or can I tell C::B which to use for a given project? This was not clear from the manual or user wiki.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10369
Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
« Reply #1 on: March 21, 2010, 12:55:30 pm »
Yes, it uses the file extension -> .c - pure C, .cpp,.C,c++,cxx -> C++
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7220
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
« Reply #2 on: March 21, 2010, 01:04:22 pm »
Yes, it uses the file extension -> .c - pure C, .cpp,.C,c++,cxx -> C++
The capital C as file-ending is detected as c-file also !!

Offline Mountaingod

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
« Reply #3 on: March 21, 2010, 02:12:02 pm »
Thanks, that's what I needed.

I assume C::B decides based on the extensions of every file in a project? If so, does it make any decisions based on '.h' files? I would guess not, except that my last development tool (Notepad++) in fact did this (adopting C++, rather than C, syntax highlighting which I kept needing to correct). So it's worth me making sure!

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
« Reply #4 on: March 21, 2010, 02:54:00 pm »
Thanks, that's what I needed.

I assume C::B decides based on the extensions of every file in a project? If so, does it make any decisions based on '.h' files? I would guess not, except that my last development tool (Notepad++) in fact did this (adopting C++, rather than C, syntax highlighting which I kept needing to correct). So it's worth me making sure!

Files ending with ".h" are not normally compiled directly -- they are included as part of another source file (that does end with ".c" or "cpp" or whatever).  Therefore C::B doesn't need to decide which compiler to call for a *.h file.

However, the editor does do syntax highlighting based upon the file extension; in this case all C/C++ files are treated the same.  But the editor does not do compiling -- it just edits.

Ringo

Offline Mountaingod

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
« Reply #5 on: March 21, 2010, 06:58:16 pm »
Of course, I should have realised. Thanks again for all your clarifications.