Detect the OS at compile time.
c++11 dependency free header only
conan search detectYou can also download the sources.
Documentation and more detailed examples are hosted on Github Pages.
Using compiler predefined macros we can detect the operating system before compilation. This allows us to conditionally compile code:
#include <detect/macros.hpp>
#if PLATFORM_LINUX
...
#endifIf we can check this at runtime then constants are more flexible:
#include <detect/constants.hpp>
if (platform::os == platform::linux) {
...
}The exported macros are:
PLATFORM_LINUXPLATFORM_SOLARISPLATFORM_WINDOWSPLATFORM_BSDPLATFORM_MACOSPLATFORM_IOSPLATFORM_WATCHOSPLATFORM_TVOSPLATFORM_ANDROIDPLATFORM_UNIXPLATFORM_POSIXPLATFORM_MOBILE
The compile time constants are contained in the platform namesapce:
namespace platform {
enum OS {
Linux,
Solaris,
BSD,
Windows,
macOS,
iOS,
watchOS,
tvOS,
Android,
}
constexpr OS os
constexpr bool unix
constexpr bool posix
constexpr bool mobile
constexpr char sep
constexpr char devnull[]
}To install dependencies:
yarn install
pip install .[all]
conan install .To run tests:
scons testTo generate the documentation locally:
scons docsTo run linters:
scons lintTo run formatters:
scons formatThe ConanCenter doesn't yet allow users to publish packages independently. Package recipes are submitted to the conan-center-index. A copy of this recipe is kept in this repository in the publish folder. This allows us to test that the recipe is compatible with new versions and makes it easier to submit updates to the conan-center-index.
To test the recipe can build the latest published tag:
conan create publish/all/conanfile.py --version $(yq -r ".versions | keys | .[0]" publish/config.yml)This will fetch the sources and create a locally cached version of the package. This version can also be published to a local remote for testing:
conan upload <package>/<version> -r <remote>Scripts are defined in the scripts folder and can be invoked with toolchains:
To generate header guards:
npx toolchains guardsPlease read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.
This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.
Bump2version is used to version and tag changes. For example:
bump2version patch- Joel Lefkowitz - Initial work
Lots of love to the open source community!


