Re: [Boost-bugs] [Boost C++ Libraries] #2329: GCC preprocessing error

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2329: GCC preprocessing error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-09-16 20:48:55


#2329: GCC preprocessing error
--------------------------------+-------------------------------------------
  Reporter: rtelyuk_at_[hidden] | Owner: no-maintainer
      Type: Bugs | Status: closed
 Milestone: Boost 1.37.0 | Component: preprocessor
   Version: Boost 1.36.0 | Severity: Problem
Resolution: invalid | Keywords:
--------------------------------+-------------------------------------------
Changes (by danieljames):

  * status: new => closed
  * resolution: => invalid

Comment:

 Hi, this isn't a preprocessor bug, it's because of differences in the
 preprocessor implementations. The Visual C++ preprocessor doesn't follow
 the standard very closely, so without some care anything developed with it
 could easily not be portable.

 This really is something that should be sent to boost users, but I'll give
 you a few hints. First the problem you described is caused by your use of
 BOOST_PP_COMMA. It's getting expanded much earlier of gcc, and treated as
 a parameter seperator. A better way to do this would be something like:

 {{{
 #define DECLARE_ARG_CONSTRUCT_INIT(r, d, arg) \
     BOOST_PP_TUPLE_ELEM(2, 1, arg) ( BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,
 1, arg), _UL()) )

 #define DECLARE_T ... \
 BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM( \
   DECLARE_ARG_CONSTRUCT_INIT, BOOST_PP_SEQ_SIZE(memeber_seq),
 memeber_seq)) \
   ...
 }}}

 You'll notice I used BOOST_PP_CAT to concatenate the underscore. This is
 because you're relying on a bug in Visual C++ which concatenates the
 results of functions with the following token. So instead of:

 {{{
 BOOST_PP_TUPLE_ELEM(2, 1, arg)_UL()
 }}}

 use:

 {{{
 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, arg), _UL())
 }}}

 You've got a lot of pointless macros, such as _PRIVATE, _PUBLIC,
 _PROTECTED, _NOP and _UL. You can just use the keyword or symbol. Also
 names that start with an underscore and a capital are reserved, so you
 shouldn't use them. The code above becomes:

 {{{
 BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, arg), _)
 }}}

 You're also going to run into trouble with `member_access##:` because you
 can only concatenate with numbers and identifiers (i.e. `[0-9A-Za-z_]`).
 `member_access :` should be fine - no concatenation is required.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2329#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC