Boost logo

Boost Users :

Subject: Re: [Boost-users] [polygon] Compiling polygon under Windows
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2010-11-29 14:31:03


Josh Pieper wrote:
> Hello,
>
> I have been compiling boost::polygon under Windows (VS2008, MSVC9.0
> specifically) and have run into a minor problem with boost::polygon's
> detection of Microsoft's compiler. Specifically, it tests for the
> WIN32 preprocessor define instead of _WIN32. WIN32 isn't actually
> defined by the compiler, but by windows.h, and not all translation
> units actually need to include that header. _WIN32 is defined by the
> compiler, and boost has the similar BOOST_MSVC preprocessor define
> which could also be used.
>
> While there is some disagreement among the existing boost libraries
> about the best mechanism to check this, some check _WIN32, some check
> BOOST_MSVC, and some check both or others at the same time.
>
> I propose the following patch to the 1.45.0 boost::polygon sources to
> make the detection of the MSVC compiler more robust.
>
> Regards,
> Josh Pieper
>
> Index: boost/polygon/gtl.hpp
> ===================================================================
> --- boost/polygon/gtl.hpp
> +++ boost/polygon/gtl.hpp
> @@ -12,7 +12,7 @@
> #pragma warning (disable:1125)
> #endif
>
> -#ifdef WIN32
> +#ifdef _WIN32
> #pragma warning( disable: 4996 )
> #pragma warning( disable: 4800 )
> #endif
> Index: polygon/isotropy.hpp
> ===================================================================
> --- boost/polygon/isotropy.hpp
> +++ boost/polygon/isotropy.hpp
> @@ -48,7 +48,7 @@
> #include <boost/mpl/or.hpp>
> #else
>
> -#ifdef WIN32
> +#ifdef _WIN32
> #define BOOST_POLYGON_MSVC
> #endif
> #ifdef __ICC
> @@ -290,7 +290,7 @@
>
> template <typename T>
> struct gtl_if {
> -#ifdef WIN32
> +#ifdef _WIN32
> typedef gtl_no type;
> #endif
> };

I can fix this for the next release, however, for the second change it should actually use BOOST_POLYGON_MSVC and not _WIN32. It was an oversight on my part that it was using the WIN32 instead of BOOST_POLYGON_MSVC macro. It was a bug fix I added for older versions of the ICC compiler (and EDG frontend in general) which weren't doing SFINAE properly in a way that was mutually exclusive with the way MSVC 7.1, 8 and 9 doesn't do SFINAE properly. Gcc worked either way so I singled out MSVC for the special behavior so that gcc, icc and all compilers that might use old versions of EDG frontend that I don't know about would work by default. Apparently when I made the fix I used the wrong macro name. I doubt you are using Polygon with BOOST_POLYGON_NO_DEPS defined, so it is the second instance of WIN32 that was causing you trouble and it was my error in using WIN32 instead of BOOST_POLYGON_MSVC that caused you the problem. You should see a commit to trunk soon.

Thanks,
Luke


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net