Boost logo

Boost-Build :

Subject: [Boost-build] Target OS preprocessor macro
From: mareq (mq_at_[hidden])
Date: 2012-09-04 17:15:35

I would like to conditionally execute parts of my code, depending on the
target OS. That means, that I need to define preprocessor macro (e.g.
BOOST_BUILD_TARGET_OS_LINUX), based on the value of <target-os> feature.

However, the only way how to do this, which is known to me by now is to
generate header file, containing appropriate #define directive and include
that header file into the sources. This is not very straightforward way, to
say the least.

Therefore, my question: What is the simplest way to add <define> property
into targets' property-set, which value (i.e. name of the preprocessor macro
being defined) is dependent on <target-os> property of the target in
question (e.g. <target-os>linux -> <define>BOOST_BUILD_TARGET_OS_LINUX,
<target-os>windows -> <define>BOOST_BUILD_TARGET_OS_WINDOWS, etc.).


View this message in context:
Sent from the Boost - Build mailing list archive at

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at