Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Next

Chapter 1. Boost.WinAPI

Distributed under the Boost Software License, Version 1.0.

Table of Contents

Introduction
Configuration
Using Boost.WinAPI

The Boost.WinAPI library is an abstraction layer for Windows API intended to be used internally by other Boost libraries. Boost.WinAPI is not a public library for users of Boost.

The main advantages of using Boost.WinAPI instead of Windows API directly are:

  • Avoid including <windows.h> or other Windows SDK headers in public headers of your library. Windows SDK headers are known to be dependent on a large number of configuration macros that have to be defined by the user. If your library depends on a particular API, you may not be able to rely on it being enabled by the user. On the other hand, your library cannot enforce particular Windows SDK configuration because (a) Windows SDK headers may be included before your library headers with a different set of config macros and (b) because your desired configuration may be incompatible with that of the user's code.
  • Avoid dealing with lots of macros defined by Windows SDK headers.
  • More fine grained control of the API you include in your headers.
  • Allow to select the target Windows version for Boost. This version can be different from the version user's code targets.
  • Better compatibility with different implementations of Windows SDK, like MinGW and MinGW-w64.

The implementation of Boost.WinAPI consists of a number of declarations of functions, types and constants mimicking the real declarations in Windows SDK. In some cases simple inline function wrappers are provided. As a result the runtime performance impact of Boost.WinAPI should be zero. Boost.WinAPI only depends on Boost.Config and Boost.Predef and is compatible with C++03 compilers.


Next