Boost logo

Boost :

Subject: Re: [boost] [winapi] Default target Windows version
From: Sergey Cheban (s.cheban_at_[hidden])
Date: 2013-10-23 18:40:06


24.10.2013 1:06, Andrey Semashev пишет:

> Maybe it would be a good idea to just include sdkddkver.h and then analyze
> _WIN32_WINNT value so that Boost automatically uses the right WinAPI. If the
> user does not define this macro then we use whatever the default is in the
> current SDK.
I don't think so. The default _WIN32_WINNT=0x0601 in the windows sdk is
very high but it does not break compatibility with WinXP in the most of
the cases. OTOH, if we use the _WIN32_WINNT, our library will be
incompatible with WinXP by default.

I propose the following approach:

condvar_vista.cpp:
==============================
#define _WIN32_WINNT 0x0600
#include <windows.h>
#include <condvar.hpp>

#ifdef _WIN32_WINNT_VISTA
condvar_vista::condvar_vista()
{
   //Vista+ implementation
};
#endif //_WIN32_WINNT_VISTA
==============================

condvar_win2k.cpp:
==============================
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <condvar.hpp>

condvar_win2k::condvar_win2k()
{
   //Win2k implementation
};
==============================

condvar.hpp:
==============================
#if !defined( _WIN32_WINNT )
# pragma message( "_WIN32_WINNT is not defined" )
//ToDo: define USE_VISTA by default after 08 Apr 2014
#else if _WIN32_WINNT >= 0x0600 //Vista+
# define USE_VISTA
#endif

#include <windows.h>

#ifdef _WIN32_WINNT_VISTA
class condvar_vista{...};
#endif //_WIN32_WINNT_VISTA

class condvar_w2k{...};

#ifdef USE_VISTA
typedef condvar_vista condvar;
#else
typedef condvar_w2k condvar;
#endif
==============================

With this approach, our library will contain both implementations of the
condvar class (providing the SDK is not too old). To choose between
them, developers will have to define _WIN32_WINNT for their applications
but will not have to recompile our library.

What do you think about this idea?

-- 
Best regards,
Sergey Cheban

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk