<div dir="ltr"><p>Hi,</p><p></p><p>I&#39;ve written some preprocessor directives to generate functions for a
 class. With Boost 1.55 everything works fine with gcc and clang. When I try to change to 
Boost 1.57 I&#39;ve got some strange compile errors.</p><p></p><p></p><p>I&#39;m happy if someone could help.</p><p></p><p>Thanks</p><p>Franz<br></p><p><br></p>

<p>gcc 4.9.1 failed with error:</p><p></p><p>    test.cpp:33:1: error: macro &quot;BOOST_PP_SEQ_ELEM_III&quot; requires 2 arguments, but only 1 given<br>       )<br>     ^<br>    test.cpp:33:1: error: macro &quot;BOOST_PP_VARIADIC_ELEM_2&quot; requires 4 arguments, but only 2 given<br>    test.cpp:60:1: error: macro &quot;BOOST_PP_SEQ_ELEM_III&quot; requires 2 arguments, but only 1 given<br>     MY_FUNCTION_BEGIN((b))<br>     ^<br>    test.cpp:60:1: error: macro &quot;BOOST_PP_VARIADIC_ELEM_2&quot; requires 4 arguments, but only 2 give</p><p><br></p><p>clang 3.5.0 failed with error:</p><p>    test.cpp:30:3: error: too few arguments provided to function-like macro invocation<br>      MY_FUNCTIONS( \<br>      ^<br>    test.cpp:25:25: note: expanded from macro &#39;MY_FUNCTIONS&#39;<br>      BOOST_PP_SEQ_FOR_EACH(FUNCTION_DECL, _, seq)<br>                            ^<br>    ..../boost.1_57_0/boost/preprocessor/seq/for_each.hpp:26:67: note: expanded from macro &#39;BOOST_PP_SEQ_FOR_EACH&#39;<br>    #    define BOOST_PP_SEQ_FOR_EACH(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil)), BOOST_PP_SEQ_FOR_EACH_P, BOOST_PP_SEQ_FOR_EACH_O, BOOST_PP_SEQ_FOR_EACH_M)<br>                                                                      ^<br>    ..../boost.1_57_0/boost/preprocessor/repetition/detail/for.hpp:22:78: note: expanded from macro &#39;BOOST_PP_FOR_1&#39;<br>    # define BOOST_PP_FOR_1(s, p, o, m) BOOST_PP_FOR_1_C(BOOST_PP_BOOL(p(2, s)), s, p, o, m)<br>                                                                                 ^<br>    note: (skipping 18 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)<br>    packages/boost/boost_i4/boost/preprocessor/seq/elem.hpp:22:39: note: expanded from macro &#39;BOOST_PP_SEQ_ELEM&#39;<br>    #    define BOOST_PP_SEQ_ELEM(i, seq) BOOST_PP_SEQ_ELEM_I(i, seq)<br>                                          ^<br>    packages/boost/boost_i4/boost/preprocessor/seq/elem.hpp:41:45: note: expanded from macro &#39;BOOST_PP_SEQ_ELEM_I&#39;<br>    #        define BOOST_PP_SEQ_ELEM_I(i, seq) BOOST_PP_SEQ_ELEM_II(BOOST_PP_SEQ_ELEM_ ## i seq)<br>                                                ^<br>    packages/boost/boost_i4/boost/preprocessor/seq/elem.hpp:43:62: note: expanded from macro &#39;BOOST_PP_SEQ_ELEM_II&#39;<br>    #    define BOOST_PP_SEQ_ELEM_II(im) BOOST_PP_SEQ_ELEM_III(im)<br>                                                                 ^<br>    packages/boost/boost_i4/boost/preprocessor/seq/elem.hpp:44:13: note: macro &#39;BOOST_PP_SEQ_ELEM_III&#39; defined here<br>    #    define BOOST_PP_SEQ_ELEM_III(x, _) x<br></p><p><br></p><p>The program is:</p>    #include &lt;iostream&gt;<br>    <br>    #ifndef BOOST_PP_VARIADICS<br>      #define BOOST_PP_VARIADICS<br>    #endif<br>    <br>    #include &lt;boost/preprocessor.hpp&gt;<br>    <br>    #define ADD_CONST_REF(op, data, elem) elem const &amp;<br>    <br>    #define FUNCTION_DECL(r, data, tup) \<br>      double BOOST_PP_TUPLE_ELEM(0, tup) \<br>        BOOST_PP_IF(BOOST_PP_LIST_IS_NIL(BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_ELEM(1, tup))), \<br>          (), \<br>          BOOST_PP_SEQ_TO_TUPLE( \<br>            BOOST_PP_SEQ_TRANSFORM( \<br>              ADD_CONST_REF, \<br>              _, \<br>              BOOST_PP_TUPLE_TO_SEQ(BOOST_PP_LIST_TO_TUPLE(BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_ELEM(1, tup)))) \<br>            ) \<br>          ) \<br>        ) \<br>      const;<br>    <br>    #define MY_FUNCTIONS(seq) \<br>      BOOST_PP_SEQ_FOR_EACH(FUNCTION_DECL, _, seq)<br>    <br>    class Foo<br>    {<br>    public:<br>      MY_FUNCTIONS( \<br>        ((a, (int))) \<br>        ((b)       ) \<br>      )<br>    };<br>    <br>    #define ADD_ARG(op, data, elem) elem const &amp; BOOST_PP_CAT(a_, elem)<br>    <br>    #define MY_FUNCTION_BEGIN(tup) \<br>      double Foo::BOOST_PP_TUPLE_ELEM(0, tup) \<br>        BOOST_PP_IF(BOOST_PP_LIST_IS_NIL(BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_ELEM(1, tup))), \<br>          (), \<br>          BOOST_PP_SEQ_TO_TUPLE( \<br>            BOOST_PP_SEQ_TRANSFORM( \<br>              ADD_ARG, \<br>              _, \<br>              BOOST_PP_TUPLE_TO_SEQ(BOOST_PP_LIST_TO_TUPLE(BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_ELEM(1, tup)))) \<br>            ) \<br>          ) \<br>        ) const \<br>      {<br>    <br>    #define MY_FUNCTION_END() }<br>    <br>    MY_FUNCTION_BEGIN((a, (int)))<br>    {<br>      std::cout &lt;&lt; &quot;Foo::a(&quot; &lt;&lt; a_int &lt;&lt; &quot;)\n&quot;;<br>    }<br>    MY_FUNCTION_END()<br>    <br>    MY_FUNCTION_BEGIN((b))<br>    {<br>      std::cout &lt;&lt; &quot;Foo::b()\n&quot;;<br>    }<br>    MY_FUNCTION_END()<br>    <br>    int main()<br>    {<br>      Foo f;<br>      f.a(42);<br>      f.b();<br>    <br>      return 0;<br>    }<br></div>