Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Mountaingod on March 21, 2010, 12:50:09 pm

Title: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
Post by: Mountaingod on March 21, 2010, 12:50:09 pm
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.
Title: Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
Post by: oBFusCATed on March 21, 2010, 12:55:30 pm
Yes, it uses the file extension -> .c - pure C, .cpp,.C,c++,cxx -> C++
Title: Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
Post by: Jenna 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 !!
Title: Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
Post by: Mountaingod 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!
Title: Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
Post by: rcoll 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
Title: Re: When does C::B use mingw32-gcc.exe , compared with mingw32-g++.exe ?
Post by: Mountaingod on March 21, 2010, 06:58:16 pm
Of course, I should have realised. Thanks again for all your clarifications.