From dddf37f5cc6544b3f955fecfb8798bf6605de800 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Wed, 21 Nov 2007 16:44:44 +0000 Subject: [PATCH] Avoid duplicating error messages with g++. --- STL_Extension/src/CGAL/assertions.cpp | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/STL_Extension/src/CGAL/assertions.cpp b/STL_Extension/src/CGAL/assertions.cpp index 033fc3d47bf..3104feb84d9 100644 --- a/STL_Extension/src/CGAL/assertions.cpp +++ b/STL_Extension/src/CGAL/assertions.cpp @@ -58,14 +58,18 @@ _standard_error_handler( int line, const char* msg ) { +#ifdef __GNUG__ + // After g++ 3.4, std::terminate defaults to printing to std::cerr itself. + if (_error_behaviour == THROW_EXCEPTION) + return; +#endif std::cerr << "CGAL error: " << what << " violation!" << std::endl - << "Expr: " << expr << std::endl - << "File: " << file << std::endl - << "Line: " << line << std::endl; - if ( msg != 0) - std::cerr << "Explanation:" << msg << std::endl; - std::cerr << "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html" - << std::endl; + << "Expression : " << expr << std::endl + << "File : " << file << std::endl + << "Line : " << line << std::endl + << "Explanation: " << msg << std::endl + << "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html" + << std::endl; } @@ -78,12 +82,18 @@ _standard_warning_handler( const char *, int line, const char* msg ) { +#ifdef __GNUG__ + // After g++ 3.4, std::terminate defaults to printing to std::cerr itself. + if (_warning_behaviour == THROW_EXCEPTION) + return; +#endif std::cerr << "CGAL warning: check violation!" << std::endl - << "Expr: " << expr << std::endl - << "File: " << file << std::endl - << "Line: " << line << std::endl; - if ( msg != 0) - std::cerr << "Explanation:" << msg << std::endl; + << "Expression : " << expr << std::endl + << "File : " << file << std::endl + << "Line : " << line << std::endl + << "Explanation: " << msg << std::endl + << "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html" + << std::endl; } // default handler settings