Why is BOOST_OS_WINDOWS defined on Linux

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Why is BOOST_OS_WINDOWS defined on Linux

Boost - Users mailing list
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
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Why is BOOST_OS_WINDOWS defined on Linux

Boost - Users mailing list

On Thu, 3 May 2018 at 14:49 David Demelier via Boost-users <[hidden email]> 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
}  

-- chris

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Why is BOOST_OS_WINDOWS defined on Linux

Boost - Users mailing list
Le 3 mai 2018 23:27, Chris Glover <[hidden email]> a écrit :

On Thu, 3 May 2018 at 14:49 David Demelier via Boost-users <[hidden email]> 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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Why is BOOST_OS_WINDOWS defined on Linux

Boost - Users mailing list
On Fri, 4 May 2018 at 01:57 David Demelier <[hidden email]> wrote:

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.


There are some rough guidelines here:


The menu to the right, under Requirements and Guidelines contains a few related links.

The relevant bit to your question is this;

"Files intended to be processed by a C++ compiler as part of a translation unit should have a three-letter filename extension ending in "pp". Other files should not use extensions ending in "pp". This convention makes it easy to identify all of the C++ source in Boost."

So, the .h files don't require a C++ compiler and could be used in C.

-- chris


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Why is BOOST_OS_WINDOWS defined on Linux

Boost - Users mailing list
On Fri, May 04, 2018 at 11:54:41AM +0000, Chris Glover wrote:
> On Fri, 4 May 2018 at 01:57 David Demelier <[hidden email]> wrote:
> > 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.
>
> There are some rough guidelines here:
>
> https://www.boost.org/development/requirements.html

Thanks, that is handy!

> "Files intended to be processed by a C++ compiler as part of a translation
> unit should have a three-letter filename extension ending in "pp". Other
> files should not use extensions ending in "pp". This convention makes it
> easy to identify all of the C++ source in Boost."
>
> So, the .h files don't require a C++ compiler and could be used in C.

Understood, thanks for that quick replies!

Regards,

--
David
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Why is BOOST_OS_WINDOWS defined on Linux

Boost - Users mailing list
On Fri, May 4, 2018 at 7:34 AM, David Demelier via Boost-users <[hidden email]> wrote:
On Fri, May 04, 2018 at 11:54:41AM +0000, Chris Glover wrote:
> On Fri, 4 May 2018 at 01:57 David Demelier <[hidden email]> wrote:
> > 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.
>
> There are some rough guidelines here:
>
> https://www.boost.org/development/requirements.html

Thanks, that is handy!

> "Files intended to be processed by a C++ compiler as part of a translation
> unit should have a three-letter filename extension ending in "pp". Other
> files should not use extensions ending in "pp". This convention makes it
> easy to identify all of the C++ source in Boost."
>
> So, the .h files don't require a C++ compiler and could be used in C.

Understood, thanks for that quick replies!

Not just C. The Predef headers where designed to compile with C++, C, Objective C, and Objective C++. Essentially any language that uses the C preprocessor can use the Predef headers.

--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users