Boost C++ Libraries: Ticket #2983: BOOST_CHECK_EQUAL gives error (or warning) "use of old-style cast" when compiled as C++ https://svn.boost.org/trac10/ticket/2983 <p> BOOST_CHECK_EQUAL gives error (or warning) "use of old-style cast" when compiled as C++ (using g++ -Werror=old-style-cast). This is especially bad because we are supposed to use -Werror=old-style-cast in the build to keep our own code clean. Then BOOST gets in the way. We had similar issues with SDL: <a class="ext-link" href="http://bugzilla.libsdl.org/show_bug.cgi?id=537"><span class="icon">​</span>http://bugzilla.libsdl.org/show_bug.cgi?id=537</a> <a class="ext-link" href="http://bugzilla.libsdl.org/show_bug.cgi?id=538"><span class="icon">​</span>http://bugzilla.libsdl.org/show_bug.cgi?id=538</a> </p> <p> They accepted a fix that used special macros for casts: /* Use proper C++ casts when compiled as C++ to be compatible with the option + -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */ #ifdef <span class="underline">cplusplus #define SDL_reinterpret_cast(type, expression) reinterpret_cast&lt;type&gt;(expression) #define SDL_static_cast(type, expression) static_cast&lt;type&gt;(expression) #else #define SDL_reinterpret_cast(type, expression) ((type)(expression)) #define SDL_static_cast(type, expression) ((type)(expression)) #endif </span></p> <p> With that simple technique they could get their headers to work cleanly with C++ while staying compatible with C. Boost should fix this issue too. </p> <p> The following code shows how the bug can be reproduced: $ cat prov.cc #include &lt;boost/test/unit_test.hpp&gt; void f () { </p> <blockquote> <p> BOOST_CHECK_EQUAL(0, 0); </p> </blockquote> <p> } $ LANG= g++ -c -Werror=old-style-cast prov.cc prov.cc: In function 'void f()': prov.cc:3: error: use of old-style cast prov.cc:3: error: use of old-style cast </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2983 Trac 1.4.3 Gennadiy Rozental Sat, 06 Jun 2009 09:47:17 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2983#comment:1 https://svn.boost.org/trac10/ticket/2983#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Boost.Test is C++ library. No need for macro. I've changed C style casts inside Boost.Test code. there might be still some coming from other components or system headers </p> Ticket