forked from boostorg/preprocessor
66 lines
2.8 KiB
HTML
66 lines
2.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
<HTML><HEAD><TITLE>Boost PREPROCESSOR library</TITLE>
|
||
<BODY bgcolor="#ffffff">
|
||
<a href="index.htm"><IMG height=86
|
||
alt="c++boost.gif (8819 bytes)"
|
||
src="../../../c++boost.gif"
|
||
width=277 align=center></a>
|
||
<hr>
|
||
|
||
<h1>Boost PREPROCESSOR library: Known problems with specific compilers</h1>
|
||
|
||
<p> Some compilers have buggy or limited preprocessors. This page explains known
|
||
problems with specific compilers.</p>
|
||
<hr>
|
||
<h2>Contents</h2>
|
||
<ul>
|
||
<li><a href="#Metrowerks Codewarrior 7.0">Metrowerks Codewarrior 7.0</a></li>
|
||
</ul>
|
||
<HR>
|
||
<h3><a name="Metrowerks Codewarrior 7.0">Metrowerks Codewarrior 7.0</a></h3>
|
||
<p>Bad news - Metrowerks Codewarrior 7.0 has a bug in preprocessor (to be more
|
||
concrete, in function-like macro replacement mechanism) that restricts usage
|
||
of the library to only very simple cases, at least if you don't write code that
|
||
specifically address this issue; for example, the above NUMBERED_EXPRESSION
|
||
example doesn't compile on CW 7.0. Below is a simple test case that reproduces
|
||
the bug:</p>
|
||
<blockquote>
|
||
<pre>#define IDENTITY_MACRO(x) IDENTITY_MACRO_BODY(x)
|
||
#define IDENTITY_MACRO_BODY(x) x
|
||
#define COMMA_TOKEN() ,
|
||
int a IDENTITY_MACRO(COMMA_TOKEN)() b; // this works
|
||
int c IDENTITY_MACRO(IDENTITY_MACRO(COMMA_TOKEN))() d; // this doesn't
|
||
</pre>
|
||
</blockquote>
|
||
<p>Basically, what's happening here is that function-like COMMA_TOKEN macro gets
|
||
expanded _inside_ of the nested IDENTITY_MACRO call - even although it's NOT
|
||
followed by a '(' as the next preprocessing token - which is a clearly an incorrect
|
||
behavior (see 16.3 [cpp.replace] para 9 for the detailed description of the
|
||
function-like macro replacement process). I haven't submitted bug report yet,
|
||
but I am going to.</p>
|
||
<p>So, this is not a problem of the library, but probably something that needs
|
||
to be mentioned in the documentation, may be with some examples of how to workaround
|
||
the issue. Just to show one possible way around the problem, here is a NUMBERED_EXPRESSION
|
||
macro that does work on MWCW:</p>
|
||
<blockquote>
|
||
<pre>#define NUMBERED_EXPRESSION(n, x) \
|
||
BOOST_PREPROCESSOR_CAT(BOOST_, \
|
||
BOOST_PREPROCESSOR_IF( \
|
||
n \
|
||
, PREPROCESSOR_IDENTITY(x##n) \
|
||
, PREPROCESSOR_EMPTY \
|
||
))() \
|
||
/**/
|
||
</pre></blockquote>
|
||
<p align="right"><i>Reported by Aleksey Gurtovoy</i></p>
|
||
<hr>
|
||
<P><EFBFBD> Copyright Housemarque, Inc. 2001</P>
|
||
<p>Permission to copy, use, modify, sell and distribute this document is granted
|
||
provided this copyright notice appears in all copies. This document is provided
|
||
"as is" without express or implied warranty, and with no claim as to its suitability
|
||
for any purpose. </p>
|
||
<p>Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan --><!--webbot bot="Timestamp" endspan i-checksum="15246" --></p>
|
||
<p></p>
|
||
|
||
</BODY></HTML>
|