forked from boostorg/predef
FUlly updated docs for version 1.1.
This commit is contained in:
@@ -19,6 +19,9 @@ http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
* Addition of exclusive plus emulated definitions for platform
|
* Addition of exclusive plus emulated definitions for platform
|
||||||
and compiler detection.
|
and compiler detection.
|
||||||
|
|
||||||
[warning The big change for this version is the restructuring of the definitions to avoid duplicate definitions in one category. That is, only one `BOOST_OS_*` variant will be detected (except for sub-categories).]
|
[warning The big change for this version is the restructuring of the
|
||||||
|
definitions to avoid duplicate definitions in one category. That is, only one
|
||||||
|
`BOOST_OS_*`, `BOOST_COMP_*`, and `BOOST_PLAT_*` variant will be detected
|
||||||
|
(except for sub-categories).]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
@@ -52,7 +52,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"><p><small>Last revised: June 03, 2014 at 03:39:11 GMT</small></p></td>
|
<td align="left"><p><small>Last revised: June 04, 2014 at 03:28:01 GMT</small></p></td>
|
||||||
<td align="right"><div class="copyright-footer"></div></td>
|
<td align="right"><div class="copyright-footer"></div></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
|
@@ -37,20 +37,21 @@
|
|||||||
The headers must use the Boost Software License.
|
The headers must use the Boost Software License.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
The predef must, by default, be defined as <code class="computeroutput"><span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">)</span></code>.
|
The predef must, by default, be defined as <code class="computeroutput"><span class="identifier">BOOST_VERSION_NUMBER_NOT_AVAILABLE</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
The predef must be redefined to a non-zero value once detected.
|
The predef must be redefined to a non-zero value once detected.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
The predef must, by default, be defined to <code class="computeroutput"><span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">)</span></code> when the predef is detected.
|
The predef must, by default, be defined to <code class="computeroutput"><span class="identifier">BOOST_VERSION_NUMBER_AVAILABLE</span></code>
|
||||||
|
when the predef is detected.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
If possible, the predef will be defined as the version number detected.
|
If possible, the predef will be defined as the version number detected.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
The predef must define <code class="computeroutput"><span class="special">*</span><span class="identifier">_AVAILABLE</span></code>
|
The predef must define <code class="computeroutput"><span class="special">*</span><span class="identifier">_AVAILABLE</span></code>
|
||||||
macros.
|
macros as needed.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
The predef must define a symbolic constant string name macro.
|
The predef must define a symbolic constant string name macro.
|
||||||
@@ -58,6 +59,16 @@
|
|||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
The predef must declare itself, after being defined, for the testing system.
|
The predef must declare itself, after being defined, for the testing system.
|
||||||
</li>
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
The predef must guarantee that it is the only one defined as detected per
|
||||||
|
category.
|
||||||
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
But a predef can define <code class="computeroutput"><span class="special">*</span><span class="identifier">_EMULATED</span></code> macros to indicate that it
|
||||||
|
was previously detected by another header and is being "emulated"
|
||||||
|
by the system. Note that the <code class="computeroutput"><span class="special">*</span><span class="identifier">_AVAILABLE</span></code> macros must still be defined
|
||||||
|
in this situation.
|
||||||
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
And there are some extra guidelines that predef headers should follow:
|
And there are some extra guidelines that predef headers should follow:
|
||||||
@@ -97,6 +108,12 @@ http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
<span class="preprocessor">#ifndef</span> <span class="identifier">BOOST_PREDEF_category_tag_H</span>
|
<span class="preprocessor">#ifndef</span> <span class="identifier">BOOST_PREDEF_category_tag_H</span>
|
||||||
<span class="preprocessor">#define</span> <span class="identifier">BOOST_PREDEF_category_tag_H</span>
|
<span class="preprocessor">#define</span> <span class="identifier">BOOST_PREDEF_category_tag_H</span>
|
||||||
</pre>
|
</pre>
|
||||||
|
<p>
|
||||||
|
If the detection depends on the detection of another predef you should include
|
||||||
|
those headers here.
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">predef</span><span class="special">/</span><span class="identifier">CATEGORY_TAG</span><span class="special">/</span><span class="identifier">DEPENDENCY</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span>
|
||||||
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Depending on how you are defining the predef you will at minimum have to include
|
Depending on how you are defining the predef you will at minimum have to include
|
||||||
the <code class="computeroutput"><span class="identifier">version_number</span><span class="special">.</span><span class="identifier">h</span></code> header. But you might also want to include
|
the <code class="computeroutput"><span class="identifier">version_number</span><span class="special">.</span><span class="identifier">h</span></code> header. But you might also want to include
|
||||||
@@ -120,7 +137,7 @@ http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
Documentation about what is detected.
|
Documentation about what is detected.
|
||||||
*/</span>
|
*/</span>
|
||||||
|
|
||||||
<span class="preprocessor">#define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">)</span>
|
<span class="preprocessor">#define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER_NOT_AVAILABLE</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Next is the detection and definition of the particular predef. The structure
|
Next is the detection and definition of the particular predef. The structure
|
||||||
@@ -130,27 +147,29 @@ Documentation about what is detected.
|
|||||||
<span class="identifier">BOOST_category_tag</span></code>" which undefines
|
<span class="identifier">BOOST_category_tag</span></code>" which undefines
|
||||||
the zero-value default. The rest is up to the you how to do the checks for
|
the zero-value default. The rest is up to the you how to do the checks for
|
||||||
defining the version. But at minimum it must "<code class="computeroutput"><span class="preprocessor">#define</span>
|
defining the version. But at minimum it must "<code class="computeroutput"><span class="preprocessor">#define</span>
|
||||||
<span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">)</span></code>" as the fallback to minimally indicate
|
<span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER_AVAILABLE</span></code>"
|
||||||
that the predef was detected:
|
as the fallback to minimally indicate that the predef was detected:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="special">(</span><span class="identifier">condition_a</span><span class="special">)</span>
|
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="special">(</span><span class="identifier">condition_a</span><span class="special">)</span>
|
||||||
<span class="preprocessor"># undef</span> <span class="identifier">BOOST_category_tag</span>
|
<span class="preprocessor"># undef</span> <span class="identifier">BOOST_category_tag</span>
|
||||||
<span class="preprocessor"># if</span> <span class="special">(</span><span class="identifier">condition_b</span><span class="special">)</span>
|
<span class="preprocessor"># if</span> <span class="special">(</span><span class="identifier">condition_b</span><span class="special">)</span>
|
||||||
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="identifier">major</span><span class="special">,</span><span class="identifier">minor</span><span class="special">,</span><span class="identifier">patch</span><span class="special">)</span>
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="identifier">major</span><span class="special">,</span><span class="identifier">minor</span><span class="special">,</span><span class="identifier">patch</span><span class="special">)</span>
|
||||||
<span class="preprocessor"># else</span>
|
<span class="preprocessor"># else</span>
|
||||||
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">)</span>
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER_AVAILABLE</span>
|
||||||
<span class="preprocessor"># endif</span>
|
<span class="preprocessor"># endif</span>
|
||||||
<span class="preprocessor">#endif</span>
|
<span class="preprocessor">#endif</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
We also need to provide the <code class="computeroutput"><span class="special">*</span><span class="identifier">_AVAILABLE</span></code> versions of the predef. And for
|
We also need to provide the <code class="computeroutput"><span class="special">*</span><span class="identifier">_AVAILABLE</span></code> versions of the predef.
|
||||||
convenience we also want to provide a <code class="computeroutput"><span class="special">*</span><span class="identifier">_NAME</span></code> macro:
|
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="identifier">BOOST_category_tag</span>
|
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="identifier">BOOST_category_tag</span>
|
||||||
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag_AVAILABLE</span>
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag_AVAILABLE</span>
|
||||||
<span class="preprocessor">#endif</span>
|
<span class="preprocessor">#endif</span>
|
||||||
|
</pre>
|
||||||
<span class="preprocessor">#define</span> <span class="identifier">BOOST_catagory_tag_NAME</span> <span class="string">"Name"</span>
|
<p>
|
||||||
|
And for convenience we also want to provide a <code class="computeroutput"><span class="special">*</span><span class="identifier">_NAME</span></code> macro:
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_catagory_tag_NAME</span> <span class="string">"Name"</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
The testing of the predef macros is automated to generate checks for all the
|
The testing of the predef macros is automated to generate checks for all the
|
||||||
@@ -168,6 +187,84 @@ Documentation about what is detected.
|
|||||||
</pre>
|
</pre>
|
||||||
<h4>
|
<h4>
|
||||||
<a name="predef.adding_new_predefs.h2"></a>
|
<a name="predef.adding_new_predefs.h2"></a>
|
||||||
|
<span class="phrase"><a name="predef.adding_new_predefs.adding_exclusive_predefs"></a></span><a class="link" href="adding_new_predefs.html#predef.adding_new_predefs.adding_exclusive_predefs">Adding
|
||||||
|
exclusive predefs</a>
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
For headers of predefs that need to be mutually exclusive in the detection
|
||||||
|
we need to add checks and definitions to detect when the predef is detected
|
||||||
|
by multiple headers.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Internally compiler, operating system, and platforms define <code class="computeroutput"><span class="identifier">BOOST_PREDEF_DETAIL_COMP_DETECTED</span></code>,
|
||||||
|
<code class="computeroutput"><span class="identifier">BOOST_PREDEF_DEFAIL_OS_DETECTED</span></code>,
|
||||||
|
and <code class="computeroutput"><span class="identifier">BOOST_PREDEF_DETAIL_PLAT_DETECTED</span></code>
|
||||||
|
respectively when the predef is first detected. This is used to guard against
|
||||||
|
multiple definition of the detection in later included headers. In those cases
|
||||||
|
the detection would instead be written as:
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="special">!</span><span class="identifier">BOOST_PREDEF_DETAIL_category_DETECTED</span> <span class="special">&&</span> <span class="special">(</span><span class="identifier">condition_a</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># undef</span> <span class="identifier">BOOST_category_tag</span>
|
||||||
|
<span class="preprocessor"># if</span> <span class="special">(</span><span class="identifier">condition_b</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="identifier">major</span><span class="special">,</span><span class="identifier">minor</span><span class="special">,</span><span class="identifier">patch</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># else</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># endif</span>
|
||||||
|
<span class="preprocessor">#endif</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
And we also include a header that defines the <code class="computeroutput"><span class="special">*</span><span class="identifier">_DETECTED</span></code> macro when we have the detection:
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="identifier">BOOST_category_tag</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag_AVAILABLE</span>
|
||||||
|
<span class="preprocessor"># include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">predef</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">CATEGORY_detected</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span>
|
||||||
|
<span class="preprocessor">#endif</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
Everything else about the header is the same as the basic detection header.
|
||||||
|
</p>
|
||||||
|
<h4>
|
||||||
|
<a name="predef.adding_new_predefs.h3"></a>
|
||||||
|
<span class="phrase"><a name="predef.adding_new_predefs.adding_an_exclusive_but_emulated"></a></span><a class="link" href="adding_new_predefs.html#predef.adding_new_predefs.adding_an_exclusive_but_emulated">Adding
|
||||||
|
an exclusive but emulated predef</a>
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
Because compilers are frequently emulated by other compilers we both want to
|
||||||
|
have exclusive detection of the compiler and also provide information that
|
||||||
|
we detected the emulation of the compiler. To accomplish this we define a local
|
||||||
|
<code class="computeroutput"><span class="special">*</span><span class="identifier">_DETECTION</span></code>
|
||||||
|
macro for the compiler detection. And conditionally define either the base
|
||||||
|
compiler predef <code class="computeroutput"><span class="identifier">BOOST_COMP_compiler</span></code>
|
||||||
|
or the alternate <code class="computeroutput"><span class="identifier">BOOST_COMP_compiler_EMULATED</span></code>
|
||||||
|
predef.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The initial detection would look like:
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#if</span> <span class="special">(</span><span class="identifier">condition_a</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># if</span> <span class="special">(</span><span class="identifier">condition_b</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_COMP_tag_DETECTION</span> <span class="identifier">BOOST_VERSION_NUMBER</span><span class="special">(</span><span class="identifier">major</span><span class="special">,</span><span class="identifier">minor</span><span class="special">,</span><span class="identifier">patch</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># else</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_COMP_tag_DETECTION</span> <span class="identifier">BOOST_VERSION_NUMBER_AVAILABLE</span>
|
||||||
|
<span class="preprocessor"># endif</span>
|
||||||
|
<span class="preprocessor">#endif</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
And then we can conditionally define the base or emulated predefs:
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="preprocessor">#ifdef</span> <span class="identifier">BOOST_COMP_tag_DETECTION</span>
|
||||||
|
<span class="preprocessor"># if</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">BOOST_PREDEF_DETAIL_COMP_DETECTED</span><span class="special">)</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_COMP_tag_EMULATED</span> <span class="identifier">BOOST_COMP_tag_DETECTION</span>
|
||||||
|
<span class="preprocessor"># else</span>
|
||||||
|
<span class="preprocessor"># undef</span> <span class="identifier">BOOST_COMP_tag</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_COMP_tag</span> <span class="identifier">BOOST_COMP_tag_DETECTION</span>
|
||||||
|
<span class="preprocessor"># endif</span>
|
||||||
|
<span class="preprocessor"># define</span> <span class="identifier">BOOST_category_tag_AVAILABLE</span>
|
||||||
|
<span class="preprocessor"># include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">predef</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">comp_detected</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span>
|
||||||
|
<span class="preprocessor">#endif</span>
|
||||||
|
</pre>
|
||||||
|
<h4>
|
||||||
|
<a name="predef.adding_new_predefs.h4"></a>
|
||||||
<span class="phrase"><a name="predef.adding_new_predefs.using_utility_pattern_macros"></a></span><a class="link" href="adding_new_predefs.html#predef.adding_new_predefs.using_utility_pattern_macros">Using utility
|
<span class="phrase"><a name="predef.adding_new_predefs.using_utility_pattern_macros"></a></span><a class="link" href="adding_new_predefs.html#predef.adding_new_predefs.using_utility_pattern_macros">Using utility
|
||||||
pattern macros</a>
|
pattern macros</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
@@ -51,7 +51,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr><td align="left" valign="top"><p>
|
<tr><td align="left" valign="top"><p>
|
||||||
The big change for this version is the restructuring of the definitions to
|
The big change for this version is the restructuring of the definitions to
|
||||||
avoid duplicate definitions in one category. That is, only one <code class="computeroutput"><span class="identifier">BOOST_OS_</span><span class="special">*</span></code>
|
avoid duplicate definitions in one category. That is, only one <code class="computeroutput"><span class="identifier">BOOST_OS_</span><span class="special">*</span></code>,
|
||||||
|
<code class="computeroutput"><span class="identifier">BOOST_COMP_</span><span class="special">*</span></code>,
|
||||||
|
and <code class="computeroutput"><span class="identifier">BOOST_PLAT_</span><span class="special">*</span></code>
|
||||||
variant will be detected (except for sub-categories).
|
variant will be detected (except for sub-categories).
|
||||||
</p></td></tr>
|
</p></td></tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
@@ -204,7 +204,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
`_M_ARM'
|
<code class="computeroutput"><span class="identifier">_M_ARM</span></code>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@@ -145,6 +145,24 @@
|
|||||||
</p>
|
</p>
|
||||||
<h4>
|
<h4>
|
||||||
<a name="predef.using_the_predefs.h0"></a>
|
<a name="predef.using_the_predefs.h0"></a>
|
||||||
|
<span class="phrase"><a name="predef.using_the_predefs.the_emulated_macros"></a></span><a class="link" href="using_the_predefs.html#predef.using_the_predefs.the_emulated_macros">The
|
||||||
|
<code class="computeroutput"><span class="special">*</span><span class="identifier">_EMULATED</span></code>
|
||||||
|
macros</a>
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
Predef definitions are guaranteed to be uniquely detected within one category.
|
||||||
|
But there are contexts under which multiple underlying detections are possible.
|
||||||
|
The well known example of this is detection of GCC and MSVC compilers which
|
||||||
|
are commonly emulated by other compilers by defining the same base macros.
|
||||||
|
To account for this detection headers are allowed to define <code class="computeroutput"><span class="special">*</span><span class="identifier">_EMULATED</span></code> predefs when this situation is
|
||||||
|
detected. The emulated predefs will be set to the version number of the detection
|
||||||
|
instead of the regular predef macro for that detection. For example MSVC will
|
||||||
|
set <code class="computeroutput"><span class="identifier">BOOST_COMP_MSVC_EMULATED</span></code>
|
||||||
|
but not set <code class="computeroutput"><span class="identifier">BOOST_COM_MSVC</span></code>,
|
||||||
|
and it will also set <code class="computeroutput"><span class="identifier">BOOST_COMP_MSVC_AVAILABLE</span></code>.
|
||||||
|
</p>
|
||||||
|
<h4>
|
||||||
|
<a name="predef.using_the_predefs.h1"></a>
|
||||||
<span class="phrase"><a name="predef.using_the_predefs.using_the_boost_version_number_m"></a></span><a class="link" href="using_the_predefs.html#predef.using_the_predefs.using_the_boost_version_number_m">Using the
|
<span class="phrase"><a name="predef.using_the_predefs.using_the_boost_version_number_m"></a></span><a class="link" href="using_the_predefs.html#predef.using_the_predefs.using_the_boost_version_number_m">Using the
|
||||||
<code class="computeroutput"><span class="identifier">BOOST_VERSION_NUMBER</span></code> macro</a>
|
<code class="computeroutput"><span class="identifier">BOOST_VERSION_NUMBER</span></code> macro</a>
|
||||||
</h4>
|
</h4>
|
||||||
|
115
doc/predef.qbk
115
doc/predef.qbk
@@ -223,6 +223,17 @@ detected. I.e. a definition equivalent to:
|
|||||||
Also for each aspect there is a macro defined with a descriptive
|
Also for each aspect there is a macro defined with a descriptive
|
||||||
name of what the detection is.
|
name of what the detection is.
|
||||||
|
|
||||||
|
[heading The `*_EMULATED` macros]
|
||||||
|
|
||||||
|
Predef definitions are guaranteed to be uniquely detected within one category.
|
||||||
|
But there are contexts under which multiple underlying detections are possible.
|
||||||
|
The well known example of this is detection of GCC and MSVC compilers which are
|
||||||
|
commonly emulated by other compilers by defining the same base macros. To
|
||||||
|
account for this detection headers are allowed to define `*_EMULATED` predefs
|
||||||
|
when this situation is detected. The emulated predefs will be set to the
|
||||||
|
version number of the detection instead of the regular predef macro for that
|
||||||
|
detection. For example MSVC will set `BOOST_COMP_MSVC_EMULATED` but not set `BOOST_COM_MSVC`, and it will also set `BOOST_COMP_MSVC_AVAILABLE`.
|
||||||
|
|
||||||
[heading Using the `BOOST_VERSION_NUMBER` macro]
|
[heading Using the `BOOST_VERSION_NUMBER` macro]
|
||||||
|
|
||||||
All the predefs are defined to be a use of the `BOOST_VERSION_NUMBER` macro.
|
All the predefs are defined to be a use of the `BOOST_VERSION_NUMBER` macro.
|
||||||
@@ -276,15 +287,21 @@ the same structure and requirements.
|
|||||||
All predefs need to follow a set of requirements:
|
All predefs need to follow a set of requirements:
|
||||||
|
|
||||||
* The headers must use the Boost Software License.
|
* The headers must use the Boost Software License.
|
||||||
* The predef must, by default, be defined as `BOOST_VERSION_NUMBER(0,0,0)`.
|
* The predef must, by default, be defined as `BOOST_VERSION_NUMBER_NOT_AVAILABLE`.
|
||||||
* The predef must be redefined to a non-zero value once detected.
|
* The predef must be redefined to a non-zero value once detected.
|
||||||
* The predef must, by default, be defined to `BOOST_VERSION_NUMBER(0,0,1)`
|
* The predef must, by default, be defined to `BOOST_VERSION_NUMBER_AVAILABLE`
|
||||||
when the predef is detected.
|
when the predef is detected.
|
||||||
* If possible, the predef will be defined as the version number detected.
|
* If possible, the predef will be defined as the version number detected.
|
||||||
* The predef must define `*_AVAILABLE` macros.
|
* The predef must define `*_AVAILABLE` macros as needed.
|
||||||
* The predef must define a symbolic constant string name macro.
|
* The predef must define a symbolic constant string name macro.
|
||||||
* The predef must declare itself, after being defined, for the testing
|
* The predef must declare itself, after being defined, for the testing
|
||||||
system.
|
system.
|
||||||
|
* The predef must guarantee that it is the only one defined as detected
|
||||||
|
per category.
|
||||||
|
* But a predef can define `*_EMULATED` macros to indicate that it was
|
||||||
|
previously detected by another header and is being "emulated" by the
|
||||||
|
system. Note that the `*_AVAILABLE` macros must still be defined in this
|
||||||
|
situation.
|
||||||
|
|
||||||
And there are some extra guidelines that predef headers should follow:
|
And there are some extra guidelines that predef headers should follow:
|
||||||
|
|
||||||
@@ -315,6 +332,13 @@ http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
#define BOOST_PREDEF_category_tag_H
|
#define BOOST_PREDEF_category_tag_H
|
||||||
``
|
``
|
||||||
|
|
||||||
|
If the detection depends on the detection of another predef you should
|
||||||
|
include those headers here.
|
||||||
|
|
||||||
|
``
|
||||||
|
#include <boost/predef/CATEGORY_TAG/DEPENDENCY.h>
|
||||||
|
``
|
||||||
|
|
||||||
Depending on how you are defining the predef you will at minimum have
|
Depending on how you are defining the predef you will at minimum have
|
||||||
to include the `version_number.h` header. But you might also want to
|
to include the `version_number.h` header. But you might also want to
|
||||||
include the `make.h` header for the version number decomposing utility
|
include the `make.h` header for the version number decomposing utility
|
||||||
@@ -340,7 +364,7 @@ for the macro. In particular this works for the popular Eclipse IDE:
|
|||||||
Documentation about what is detected.
|
Documentation about what is detected.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_category_tag BOOST_VERSION_NUMBER(0,0,0)
|
#define BOOST_category_tag BOOST_VERSION_NUMBER_NOT_AVAILABLE
|
||||||
``
|
``
|
||||||
|
|
||||||
Next is the detection and definition of the particular predef. The
|
Next is the detection and definition of the particular predef. The
|
||||||
@@ -349,7 +373,7 @@ place further version detection inside this. The first action inside
|
|||||||
the overall check is to "`#undef BOOST_category_tag`" which undefines
|
the overall check is to "`#undef BOOST_category_tag`" which undefines
|
||||||
the zero-value default. The rest is up to the you how to do the checks
|
the zero-value default. The rest is up to the you how to do the checks
|
||||||
for defining the version. But at minimum it must
|
for defining the version. But at minimum it must
|
||||||
"`#define BOOST_category_tag BOOST_VERSION_NUMBER(0,0,1)`" as the fallback
|
"`#define BOOST_category_tag BOOST_VERSION_NUMBER_AVAILABLE`" as the fallback
|
||||||
to minimally indicate that the predef was detected:
|
to minimally indicate that the predef was detected:
|
||||||
|
|
||||||
``
|
``
|
||||||
@@ -358,19 +382,22 @@ to minimally indicate that the predef was detected:
|
|||||||
# if (condition_b)
|
# if (condition_b)
|
||||||
# define BOOST_category_tag BOOST_VERSION_NUMBER(major,minor,patch)
|
# define BOOST_category_tag BOOST_VERSION_NUMBER(major,minor,patch)
|
||||||
# else
|
# else
|
||||||
# define BOOST_category_tag BOOST_VERSION_NUMBER(0,0,1)
|
# define BOOST_category_tag BOOST_VERSION_NUMBER_AVAILABLE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
``
|
``
|
||||||
|
|
||||||
We also need to provide the `*_AVAILABLE` versions of the predef. And
|
We also need to provide the `*_AVAILABLE` versions of the predef.
|
||||||
for convenience we also want to provide a `*_NAME` macro:
|
|
||||||
|
|
||||||
``
|
``
|
||||||
#if BOOST_category_tag
|
#if BOOST_category_tag
|
||||||
# define BOOST_category_tag_AVAILABLE
|
# define BOOST_category_tag_AVAILABLE
|
||||||
#endif
|
#endif
|
||||||
|
``
|
||||||
|
|
||||||
|
And for convenience we also want to provide a `*_NAME` macro:
|
||||||
|
|
||||||
|
``
|
||||||
#define BOOST_catagory_tag_NAME "Name"
|
#define BOOST_catagory_tag_NAME "Name"
|
||||||
``
|
``
|
||||||
|
|
||||||
@@ -391,6 +418,78 @@ And, of course, we last need to close out the include guard:
|
|||||||
#endif
|
#endif
|
||||||
``
|
``
|
||||||
|
|
||||||
|
[heading Adding exclusive predefs]
|
||||||
|
|
||||||
|
For headers of predefs that need to be mutually exclusive in the detection
|
||||||
|
we need to add checks and definitions to detect when the predef is
|
||||||
|
detected by multiple headers.
|
||||||
|
|
||||||
|
Internally compiler, operating system, and platforms define
|
||||||
|
`BOOST_PREDEF_DETAIL_COMP_DETECTED`, `BOOST_PREDEF_DEFAIL_OS_DETECTED`, and
|
||||||
|
`BOOST_PREDEF_DETAIL_PLAT_DETECTED` respectively when the predef is first
|
||||||
|
detected. This is used to guard against multiple definition of the detection
|
||||||
|
in later included headers. In those cases the detection would instead be
|
||||||
|
written as:
|
||||||
|
|
||||||
|
``
|
||||||
|
#if !BOOST_PREDEF_DETAIL_category_DETECTED && (condition_a)
|
||||||
|
# undef BOOST_category_tag
|
||||||
|
# if (condition_b)
|
||||||
|
# define BOOST_category_tag BOOST_VERSION_NUMBER(major,minor,patch)
|
||||||
|
# else
|
||||||
|
# define BOOST_category_tag BOOST_VERSION_NUMBER(0,0,1)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
``
|
||||||
|
|
||||||
|
And we also include a header that defines the `*_DETECTED` macro when we have
|
||||||
|
the detection:
|
||||||
|
|
||||||
|
``
|
||||||
|
#if BOOST_category_tag
|
||||||
|
# define BOOST_category_tag_AVAILABLE
|
||||||
|
# include <boost/predef/detail/CATEGORY_detected.h>
|
||||||
|
#endif
|
||||||
|
``
|
||||||
|
|
||||||
|
Everything else about the header is the same as the basic detection header.
|
||||||
|
|
||||||
|
[heading Adding an exclusive but emulated predef]
|
||||||
|
|
||||||
|
Because compilers are frequently emulated by other compilers we both want
|
||||||
|
to have exclusive detection of the compiler and also provide information
|
||||||
|
that we detected the emulation of the compiler. To accomplish this we define
|
||||||
|
a local `*_DETECTION` macro for the compiler detection. And conditionally
|
||||||
|
define either the base compiler predef `BOOST_COMP_compiler` or the alternate
|
||||||
|
`BOOST_COMP_compiler_EMULATED` predef.
|
||||||
|
|
||||||
|
The initial detection would look like:
|
||||||
|
|
||||||
|
``
|
||||||
|
#if (condition_a)
|
||||||
|
# if (condition_b)
|
||||||
|
# define BOOST_COMP_tag_DETECTION BOOST_VERSION_NUMBER(major,minor,patch)
|
||||||
|
# else
|
||||||
|
# define BOOST_COMP_tag_DETECTION BOOST_VERSION_NUMBER_AVAILABLE
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
``
|
||||||
|
|
||||||
|
And then we can conditionally define the base or emulated predefs:
|
||||||
|
|
||||||
|
``
|
||||||
|
#ifdef BOOST_COMP_tag_DETECTION
|
||||||
|
# if defined(BOOST_PREDEF_DETAIL_COMP_DETECTED)
|
||||||
|
# define BOOST_COMP_tag_EMULATED BOOST_COMP_tag_DETECTION
|
||||||
|
# else
|
||||||
|
# undef BOOST_COMP_tag
|
||||||
|
# define BOOST_COMP_tag BOOST_COMP_tag_DETECTION
|
||||||
|
# endif
|
||||||
|
# define BOOST_category_tag_AVAILABLE
|
||||||
|
# include <boost/predef/detail/comp_detected.h>
|
||||||
|
#endif
|
||||||
|
``
|
||||||
|
|
||||||
[heading Using utility pattern macros]
|
[heading Using utility pattern macros]
|
||||||
|
|
||||||
By including:
|
By including:
|
||||||
|
@@ -26,7 +26,7 @@ http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
[[`__thumb__`] [__predef_detection__]]
|
[[`__thumb__`] [__predef_detection__]]
|
||||||
[[`__TARGET_ARCH_ARM`] [__predef_detection__]]
|
[[`__TARGET_ARCH_ARM`] [__predef_detection__]]
|
||||||
[[`__TARGET_ARCH_THUMB`] [__predef_detection__]]
|
[[`__TARGET_ARCH_THUMB`] [__predef_detection__]]
|
||||||
[[`_M_ARM'] [__predef_detection__]]
|
[[`_M_ARM`] [__predef_detection__]]
|
||||||
|
|
||||||
[[`__arm64`] [8.0.0]]
|
[[`__arm64`] [8.0.0]]
|
||||||
[[`__TARGET_ARCH_ARM`] [V.0.0]]
|
[[`__TARGET_ARCH_ARM`] [V.0.0]]
|
||||||
|
Reference in New Issue
Block a user