Code::Blocks Forums
User forums => Help => Topic started by: i3x171um on July 18, 2007, 02:52:03 am
-
It appears that the stl library is being interpreted as C instead of C++. I get 100+ errors related to basic syntax per build, and pedantic warnings about "C++ style comments not allowed in C files" from any stl header files I include.
What's up? How do I specify that files without extensions be built as C++, or that anything by default be seen as C++?
-
You should always give your files extensions that reflect the contents -- .c for C source files, .cc or .cpp or .cxx for C++ source files. This is how Code::Blocks and GCC determine whether to compile your files as C or C++.
-
STL header files are definitely not supposed to have file extensions.
I'm new to the GNU toolchain. I really would like to use Code::Blocks over Dev C++, but this is a crippling problem (probably with a simple fix).
-
You are including the header in a source file, what is the source file extension?
We believe it is ".c" which means gcc instead of g++ is being used to compile it by default.
Tim S
-
I have driver.cpp and serial.hpp. driver.cpp is writing to the debug stream via cerr, and serial.hpp uses the string and list containers. In driver.cpp I include all my STL headers, then I include serial.hpp.
In short: good guess, but no, I'm including it from a .cpp file which uses the "CPP" compiler flag in compilation, according to the file properties in Code::Blocks.
-
In that case we need to verify tool chain executables
"settings" -> "Compiler and Debugger"
Select "Tool Chain Executable" Tab
Verify that "C++ Compiler" is "mingw32-g++.exe"
Note, it could have a full path to it; this helps some Vista and GCC 4.x issues. example, "C:\MinGW\mingw32-g++.exe"
Edit: If the problem still exists please Turn on Full Compiler Logging so we can see the Build Log.
Settings -> "Compiler Debugger"
Select tab "Other Settings" on far right
Change "Compiler Logging" to "Full Command Line"
Then Try rebuilding and post the "Build Log" Then someone might see the issue cause.
Tim S
-
Ah, I figured it out. I had a feeling this is what it was...
In the GCC-G++ include directory, there is a single folder called c++. Inside that, it again has only one folder: 3.4.2. Inside that is the STL, along with some other helper headers.
My obsessive-compulsive-organizer self thought those two levels of folders (/c++/3.4.2/) were unnecessary, so I copied the contents of the 3.4.2 folder straight into the include directory. It turns out, however, that g++ expects the stl to be in include/c++/3.4.2, and chokes if it's not.
My bad. Sorry for the thread.
-
My obsessive-compulsive-organizer self thought those two levels of folders (/c++/3.4.2/) were unnecessary
LOL... Right... :lol: :lol: :lol: