Subject: CGAL users discussion list
List archive
- From: Jens Seidel <>
- To:
- Subject: [cgal-discuss] [PATCH] Compile errors using g++ --pedantic --ansi
- Date: Tue, 10 Nov 2009 17:44:51 +0100
Hi,
I fail to use CGAL 3.5's header files in strict ansi mode by using g++'s
options --pedantic --ansi. The attached patch fixes it.
Beside the usual "extra ';'" error I get also:
"error: ISO C++ forbids braced-groups within expressions". See
http://sourceware.org/ml/newlib/2006/msg00812.html for the __extension__
fix.
Jens
diff -ur CGAL-3.5/config/testfiles/CGAL_CFG_NO_STATEMENT_EXPRESSIONS.cpp CGAL-3.5.fixed/config/testfiles/CGAL_CFG_NO_STATEMENT_EXPRESSIONS.cpp --- CGAL-3.5/config/testfiles/CGAL_CFG_NO_STATEMENT_EXPRESSIONS.cpp 2009-07-24 14:42:32.000000000 +0200 +++ CGAL-3.5.fixed/config/testfiles/CGAL_CFG_NO_STATEMENT_EXPRESSIONS.cpp 2009-11-10 17:23:35.000000000 +0100 @@ -25,7 +25,7 @@ int main() { - int i = ({ int j = 2; j+j; }); + int i = __extension__ ({ int j = 2; j+j; }); assert(i == 4); return 0; } diff -ur CGAL-3.5/include/CGAL/type_traits.h CGAL-3.5.fixed/include/CGAL/type_traits.h --- CGAL-3.5/include/CGAL/type_traits.h 2009-07-24 14:43:43.000000000 +0200 +++ CGAL-3.5.fixed/include/CGAL/type_traits.h 2009-11-10 16:31:36.000000000 +0100 @@ -34,6 +34,6 @@ >::type {}; -}; +} #endif diff -ur CGAL-3.5/include/CGAL/Uncertain.h CGAL-3.5.fixed/include/CGAL/Uncertain.h --- CGAL-3.5/include/CGAL/Uncertain.h 2009-07-24 14:43:43.000000000 +0200 +++ CGAL-3.5.fixed/include/CGAL/Uncertain.h 2009-11-10 17:26:37.000000000 +0100 @@ -346,10 +346,12 @@ # define CGAL_OR(X, Y) ((X) || (Y)) #else # define CGAL_AND(X, Y) \ + __extension__ \ ({ CGAL::Uncertain<bool> CGAL_TMP = (X); \ CGAL::certainly_not(CGAL_TMP) ? CGAL::make_uncertain(false) \ : CGAL_TMP & CGAL::make_uncertain((Y)); }) # define CGAL_OR(X, Y) \ + __extension__ \ ({ CGAL::Uncertain<bool> CGAL_TMP = (X); \ CGAL::certainly(CGAL_TMP) ? CGAL::make_uncertain(true) \ : CGAL_TMP | CGAL::make_uncertain((Y)); }) diff -ur CGAL-3.5/include/CGAL/utils.h CGAL-3.5.fixed/include/CGAL/utils.h --- CGAL-3.5/include/CGAL/utils.h 2009-07-24 14:44:13.000000000 +0200 +++ CGAL-3.5.fixed/include/CGAL/utils.h 2009-11-10 16:31:58.000000000 +0100 @@ -30,32 +30,32 @@ inline T min BOOST_PREVENT_MACRO_SUBSTITUTION ( const T& x , const T& y) { return Min<T>()( x , y ); -}; +} template< class T , class Compare > inline T min BOOST_PREVENT_MACRO_SUBSTITUTION ( const T& x , const T& y, const Compare& c) { return Min<T, Compare>(c)( x , y ); -}; +} // use Max template< class T > inline T max BOOST_PREVENT_MACRO_SUBSTITUTION ( const T& x , const T& y) { return Max<T>()( x , y ); -}; +} template< class T , class Compare > inline T max BOOST_PREVENT_MACRO_SUBSTITUTION ( const T& x , const T& y, const Compare& c) { return Max<T, Compare>(c)( x , y ); -}; +} // use Is_valid template< class T > inline bool is_valid( const T& x ) { return Is_valid< T >()( x ); -}; +} CGAL_END_NAMESPACE
- [cgal-discuss] [PATCH] Compile errors using g++ --pedantic --ansi, Jens Seidel, 11/10/2009
- Re: [cgal-discuss] [PATCH] Compile errors using g++ --pedantic --ansi, Sylvain Pion, 11/16/2009
Archive powered by MHonArc 2.6.16.