Boost C++ Libraries: Ticket #4090: Macroses BOOST_PP_SEQ_FOR_EACH_*R are not reenterable https://svn.boost.org/trac10/ticket/4090 <p> Sample: #define MY_SEQ (1)(12)(123) </p> <p> #define GENERATOR_2(r,data,i,elem) i </p> <p> #define GENERATOR_1(r,data,i,elem) BOOST_PP_SEQ_FOR_EACH_I_R(r,GENERATOR_2,*,MY_SEQ) </p> <p> #define GENERATE() BOOST_PP_SEQ_FOR_EACH_I(GENERATOR_1,*,MY_SEQ) </p> <p> GENERATE() </p> <p> Visual Studio 2005 SP1 compiler raise error: error C2065: 'GENERATOR_2' : undeclared identifier </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4090 Trac 1.4.3 Edward Diener Sun, 17 May 2015 22:53:43 GMT <link>https://svn.boost.org/trac10/ticket/4090#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4090#comment:1</guid> <description> <p> First off you are not using BOOST_PP_SEQ_FOR_EACH but BOOST_PP_SEQ_FOR_EACH_I. BOOST_PP_SEQ_FOR_EACH_I is not re-entrant to BOOST_PP_SEQ_FOR_EACH_I, for obvious reasons ( you are calling back to the same macro in the expansion of a macro and the C++ preprocessor is not re-entrant in that way ). BOOST_PP_SEQ_FOR_EACH_I is not re-entrant to BOOST_PP_SEQ_FOR_EACH_I_R, which is what you are doing above, because both share the same code for the internal BOOST_PP_FOR invocation as far as the pred, op, and macro code is concerned. </p> <p> The documentation for BOOST_PP_SEQ_FOR_EACH_I_R says that "It reenters BOOST_PP_FOR with maximum efficiency". That does not mean that it itself can be called from BOOST_PP_SEQ_FOR_EACH_I. It can't for the reason stated above. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Mon, 18 May 2015 01:09:24 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4090#comment:2 https://svn.boost.org/trac10/ticket/4090#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket