[Insight-developers] Building ITK with STD_DEBUG_MODE

Mathieu Coursolle mcoursolle at rogue-research.com
Fri May 11 13:04:25 EDT 2007


From <http://developer.apple.com/releasenotes/DeveloperTools/RN-GCC3/
index.html>

"STL debugging mode for C++

By default, libstdc++ is built with efficiency in mind, and therefore
performs little or no error checking that is not required by the C++
standard. This release adds support for the libstdc++ debug mode, which
performs run-time checking for correct usage of the C++ standard
library. Incorrect usage (such as passing an iterator to the wrong
container, or passing an invalid range to a generic algorithm) will
result in a clear error message followed by an abort, rather than an
unpredictable crash.

To enable STL debugging mode, compile your application with the -
D_GLIBCXX_DEBUG compile flag. Note that this flag changes the sizes and
behavior of standard class templates such as std::vector, and therefore
you can only link code compiled with debug mode and code compiled
without debug mode if no instantiation of a container is passed between
the two translation units. This does not mean that you are required to
recompile your entire application: for instance, if one source file uses
std::vector but std::vector doesn't occur in its public interface, that
file can be recompiled in debug mode even if the rest of the program is
not compiled in debug mode.

When it is not feasible to recompile your application, or when only
specific containers need checking, debugging containers are available as
GNU extensions. These debugging containers are functionally equivalent
to the containers used in debug mode, e.g., __gnu_debug::vector<int> is
equivalent to std::vector<int> in debug mode, but the __gnu_debug
versions can be used in either release or debug mode without changing
semantics.

Pedantic debug mode checks not only for errors, but also for usages that
rely on GNU extensions and that, while correct, may not be portable to
other compilers. In pedantic mode, for example, constructing an
std::string with a null pointer will result in an abort, not an
exception. Pedantic debug mode is not the default. To enable pedantic
debug mode, compile your program with both -D_GLIBCXX_DEBUG and -
D_GLIBCXX_DEBUG_PEDANTIC.

STL debugging mode is recommended during developent or when you suspect
an error caused by incorrect use of the C++ standard library. It is not
recommended for deployment builds, because it introduces substantial
overhead."



>What's STD_DEBUG_MODE ? Do you mean -D_GLIBCXX_DEBUG. I cannot find
>any documentation about this -D option
>
>Thanks
>-Mathieu
>
>On 5/11/07, Mathieu Coursolle <mcoursolle at rogue-research.com> wrote:
>> Hi itk developpers,
>>
>> We are currently using ITK in our project and have are running a nightly
>> dashboard:
>> RogueResearch2 / MacOSXTiger-univ
>>
>> However, we would like to use the STL_DEBUG_MODE flag in our project,
>> but it won't work with
>> ITK if it is not build with this flag too.
>>
>> So we add that flag to our dashboard build, but our ITK won't build with
>> it (See error message bellow).
>>
>> So I would like to know if anyone is able to reproduce this problem. We
>> are using gcc 4.0.1.
>>
>> If so, anyone has a clue on how this could be fixed?
>>
>> Thank you!
>>
>> Mathieu
>>
>>
>> ps: We also have a few warnings cause by ITK headers in our projects. I
>> submitted some patch files
>> which fix some of them (Bugs 4952, 4965 and 4966).
>>
>>
>>
>> Linking CXX executable ../../../bin/itkNumericsHeaderTest
>> [ 56%] Built target itkNumericsHeaderTest
>> Scanning dependencies of target itkCommonHeaderTest
>> [ 56%] Building CXX object Code/Numerics/FEM/CMakeFiles/ITKFEM.dir/
>> itkFEMLoadNode.o
>> [ 56%] Building CXX object Testing/Code/Common/CMakeFiles/
>> itkCommonHeaderTest.dir/itkCommonHeaderTest.o
>> /.../Insight/Code/Common/itkConstShapedNeighborhoodIterator.h: In member
>> function 'bool itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator::operator!=(const
>> itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator&) const':
>> /.../Insight/Code/Common/itkConstShapedNeighborhoodIterator.h:152:
>> error: 'const class __gnu_debug::_Saf
>> e_iterator<__gnu_norm::_List_const_iterator<unsigned int>,
>> __gnu_debug_def::list<unsigned int, std::allocator<unsigned int> > >'
>> has no member named 'operator!='/.../Insight/Code/Common/
>> itkConstShapedNeighborhoodIterator.h: In member function 'bool
>> itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator::operator!=(const
>> itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator&) const':
>>
>> Build Log line 1279
>>
>> File: Code/Common/itkConstShapedNeighborhoodIterator.h Line: 152CVS
>>
>> /.../Insight/Code/Common/itkConstShapedNeighborhoodIterator.h:152:
>> error: 'const class __gnu_debug::_Saf
>> e_iterator<__gnu_norm::_List_const_iterator<unsigned int>,
>> __gnu_debug_def::list<unsigned int, std::allocator<unsigned int> > >'
>> has no member named 'operator!='
>> /.../Insight/Code/Common/itkConstShapedNeighborhoodIterator.h: In member
>> function 'bool itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator::operator==(const
>> itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator&) const':
>>
>> Build Log line 1281
>>
>> File: Code/Common/itkConstShapedNeighborhoodIterator.h Line: 154CVS
>>
>> /.../Insight/Code/Common/itkConstShapedNeighborhoodIterator.h:154:
>> error: 'const class __gnu_debug::_Saf
>> e_iterator<__gnu_norm::_List_const_iterator<unsigned int>,
>> __gnu_debug_def::list<unsigned int, std::allocator<unsigned int> > >'
>> has no member named 'operator=='
>>
>> /.../Insight/Code/Common/itkConstShapedNeighborhoodIterator.h: In member
>> function 'bool itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator::operator==(const
>> itk::ConstShapedNeighborhoodIterator<TImage,
>> TBoundaryCondition>::ConstIterator&) const':
>>
>> --
>>
>>
>> ____________________________________________________________
>> Mathieu Coursolle                   mcoursolle at rogue-research.com
>> Rogue Research                      www.rogue-research.com
>> Montréal, Québec, Canada
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
>
>
>-- 
>Mathieu
>Tel: +33 6 32 13 33 40
>




More information about the Insight-developers mailing list