Boost logo

Boost Users :

Subject: Re: [Boost-users] Why is BOOST_OS_WINDOWS defined on Linux
From: David Demelier (markand_at_[hidden])
Date: 2018-05-04 05:21:40


Le 3 mai 2018 23:27, Chris Glover <c.d.glover@gmail.com> a écrit :

On Thu, 3 May 2018 at 14:49 David Demelier via Boost-users <boost-users@lists.boost.org> wrote:
Hello,

Everything is in the title, the following code compiles and shows
"Windows" even though I'm running Fedora 28. I can't understand.

    #include <iostream>

    #include <boost/predef.h>

    int main()
    {
    #if defined(BOOST_OS_WINDOWS)
        puts("Windows");
    #endif
    }

I'm using Boost 1.66 with GCC 8.0.1.

Regards,

--
David

Hi David,

The correct way to check is not if BOOST_OS_WINDOWS is defined or not, but whether it's non-zero or not.

#include <iostream>
#include <boost/predef.h>

int main()
{
#if BOOST_OS_WINDOWS
    puts("Windows");
#endif
}  

Ah! That explains everything :)

Just curious, is there some coding convention in boost? I just realized predef is the only one component that I use which use .h header suffix instead of .hpp.

Thanks.

-- 
David


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