Boost logo

Boost Users :

Subject: Re: [Boost-users] EXTERNAL: Re: 1.49 header order conflicts on Windows
From: Davidson, Josh (josh.davidson_at_[hidden])
Date: 2012-06-14 11:29:28


#include <boost/thread/thread.hpp>
#include <boost/asio.hpp>
//#include <boost/thread/recursive_mutex.hpp>
#include <iostream>
using namespace std;

int main() {
        cout << _WIN32_WINNT << endl;
        return 0;
}

This prints: 1282

Same for this (as well as each one of those headers by themselves):
//#include <boost/thread/thread.hpp>
#include <boost/asio.hpp>
//#include <boost/thread/recursive_mutex.hpp>
#include <iostream>
using namespace std;

int main() {
        cout << _WIN32_WINNT << endl;
        return 0;
}

I'm on Windows 7 x64.

-----Original Message-----
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Lars Viklund
Sent: Thursday, June 14, 2012 7:17 AM
To: boost-users_at_[hidden]
Subject: EXTERNAL: Re: [Boost-users] 1.49 header order conflicts on Windows

On Wed, Jun 13, 2012 at 07:03:01PM +0000, Davidson, Josh wrote:
> Consider this following simple app:
>
> #include <boost/thread/thread.hpp>
> #include <boost/asio.hpp>
> #include <boost/thread/recursive_mutex.hpp>
>
> If asio.hpp is moved ahead of the thread headers, the error goes away. We've been trying to dictate #include order to work around this problem, but it keeps cropping up.
>

I've got an idea to the root cause here.

The primitives like InterlockedExchange requires a minimum of XP/2003 support, so you need _WIN32_WINNT to be at least 0x501 in order to target a minimum OS version of XP.

I believe that Asio defines _WIN32_WINNT to a sufficiently high value in order to get the OS primitives it needs, and as such, implicitly ensures that the thread code gets them too.

Either Boost.Thread ought to also define this if it's not already defined, and probably error out hard with a nice message if it's not targetting a sufficiently fancy Windows version.

--
Lars Viklund | zao_at_[hidden]
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

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