Code::Blocks Forums
User forums => General (but related to Code::Blocks) => Topic started 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.
-
Yes, it uses the file extension -> .c - pure C, .cpp,.C,c++,cxx -> C++
-
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 !!
-
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!
-
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
-
Of course, I should have realised. Thanks again for all your clarifications.