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

Subject: [Boost-bugs] [Boost C++ Libraries] #2329: GCC preprocessing error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-09-16 12:31:03


#2329: GCC preprocessing error
-------------------------------+--------------------------------------------
 Reporter: rtelyuk_at_[hidden] | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: Boost 1.37.0 | Component: preprocessor
  Version: Boost 1.36.0 | Severity: Problem
 Keywords: |
-------------------------------+--------------------------------------------
 #include "boost/preprocessor.hpp"

 #define _NOP()
 #define _UL() _
 #define _SC() ;
 #define CLASS( name ) class name
 #define STRUCT( name ) struct name

 #define _PUBLIC() public
 #define _PRIVATE() private
 #define _PROTECTED() protected

 #define DECLARE_MEMBER(r, d, mem) \
     BOOST_PP_TUPLE_ELEM(2, 0, mem) BOOST_PP_TUPLE_ELEM(2, 1, mem) _SC()

 #define DECLARE_ARG_CONSTRUCT(r, d, arg) \
     BOOST_PP_TUPLE_ELEM(2, 0, arg) BOOST_PP_TUPLE_ELEM(2, 1, arg)_UL()
 BOOST_PP_EXPR_IF(BOOST_PP_LESS_EQUAL(r,d), BOOST_PP_COMMA())

 #define DECLARE_ARG_CONSTRUCT_INIT(r, d, arg) \
     BOOST_PP_TUPLE_ELEM(2, 1, arg) ( BOOST_PP_TUPLE_ELEM(2, 1, arg)_UL() )
 BOOST_PP_EXPR_IF(BOOST_PP_LESS_EQUAL(r,d), BOOST_PP_COMMA())

 #define DECLARE_T( lang_type, name, memeber_seq, member_access ) \
     lang_type(name) { \
     name ( \
     BOOST_PP_SEQ_FOR_EACH( DECLARE_ARG_CONSTRUCT,
 BOOST_PP_SEQ_SIZE(memeber_seq), memeber_seq ) \
     ) : \
     BOOST_PP_SEQ_FOR_EACH( DECLARE_ARG_CONSTRUCT_INIT,
 BOOST_PP_SEQ_SIZE(memeber_seq), memeber_seq ) \
     {} \
     member_access##: \
     BOOST_PP_SEQ_FOR_EACH( DECLARE_MEMBER , _NOP(), memeber_seq) \
     };

 #define DEF_TN( t,n ) ((t,n))

 Use in code:
 DECLARE_T( STRUCT, some, DEF_TN(int, a) DEF_TN(int, b) DEF_TN(int, c),
 _PUBLIC() )

 Two compilers MSVC++ 2005 for Win platform
 and XCode 3.0 GCC for MacOSX platform

 Result:
 MSVC++ 2005 /W4 ― preprocessing succeful:
 struct some { some ( int a_ , int b_ , int c_ ) : a ( a_ ) , b ( b_ ) ,
 c ( c_ ) {} public: int a ; int b ; int c ; };

 XCode GCC ― error: macro "BOOST_PP_EXPR_IIF" passed 3 arguments, but takes
 just 2

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2329>
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