Boost logo

Boost :

Subject: [boost] Recommended way of dealing with windows.h in headers?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-05-02 07:31:29

What's the recommended way to deal with windows.h in Boost?

I see a lot of libraries doing stuff like

#if defined( BOOST_USE_WINDOWS_H )
# include <windows.h>

namespace boost

namespace detail

#if !defined( BOOST_USE_WINDOWS_H )
   extern "C" void __stdcall Sleep( unsigned long ms );

So should libraries just declare all symbols themselves? But here the
declaration is wrong, it misses __declspec(dllimport) for example when
the runtime CRT is used, unnecessarily requiring import libraries.

WINBASEAPI/WINADVAPI macros could be used to fix that.

There is also the file

that contains a few of the types, but it doesn't seem to be used that
much except by other files in detail/win, and then again they don't
re-use WINAPI and other macros. It also seems to be lacking the

Also, why couldn't headers simply include <windef.h> then <winbase.h>?
Does that cause problems too?

Boost list run by bdawes at, gregod at, cpdaniel at, john at