std::vector debug and release build using g++

c++, debugging, g++, stl

Solution

The flag you want is `-D_GLIBCXX_DEBUG`

More debug options for libstdc++ can be found at:

http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode_using.html#debug_mode.using.mode

Problem

Possible Duplicate: GCC STL bound checking Is there something like a automatic debug version of the std:vector in the g++ STL and if not how could I achive one? What I want is to specify a debug parameter in my g++ call for example: ``` g++ -D DEBUG_ main.cpp ``` When this parameter is defined I want all my std::vectors to check their boundarys when accesing an element, the way when using vector::at(). When the parameter is omitted I want all vectors to behave as if the normal [] operator is used, meaning no performance is "wasted" for boundary checking. I heard that VC++ does something like this. So my question is how to to this using the g++?

Original source

Related problems