Boost C++ Libraries: Ticket #9633: BOOST_PP_SEQ_CAT with a sequence of comma separated pairs fails with gcc https://svn.boost.org/trac10/ticket/9633 <p> Hi, </p> <p> Code with problem : </p> <pre class="wiki">#include &lt;boost\preprocessor\seq\cat.hpp&gt; #define SOME_SEQUENCE (('a',1)) (('b',2)) (('c',3)) (('d',4)) (('e',5)) struct dummy { dummy&amp; operator()(char,int) {return *this;} }; int main() { dummy() BOOST_PP_SEQ_CAT(SOME_SEQUENCE); return 0; } </pre><p> Following code compiles with Visual 2010. (generates dummy() ('a',1)('b',2)('c',3)('d',4)('e',5);) </p> <p> With gcc, it does not compil. </p> <p> I have a collection of compilation error : </p> <p> main.cpp:3:30: error: pasting ")" and "(" does not give a valid preprocessing token </p> <p> preprocessor\seq\cat.hpp:35:37: note: in definition of macro 'BOOST_PP_SEQ_CAT_O_I' </p> <p> preprocessor/seq/fold_left.hpp:555:144: note: in expansion of macro 'BOOST_PP_SEQ_CAT_O' </p> <p> and so on </p> <p> By gcc, I mean TDM MinGW32 (from tdm-gcc-4.8.1-3.exe) </p> <p> Tried with following options : </p> <pre class="wiki">mingw32-g++.exe -std=c++0x -g -IC:\boost_1_55_0 -c "C:\sources\main.cpp" -o obj\main.o mingw32-g++.exe -std=c++1y -g -IC:\boost_1_55_0 -c "C:\sources\main.cpp" -o obj\main.o mingw32-g++.exe -g -IC:\boost_1_55_0 -c "C:\sources\main.cpp" -o obj\main.o </pre><p> Notice that following code compiles fine which can be used as a workaround : </p> <p> Code compiling : </p> <pre class="wiki">#include &lt;boost\preprocessor\seq\for_each.hpp&gt; #define SOME_SEQUENCE (('a',1)) (('b',2)) (('c',3)) (('d',4)) (('e',5)) #define MACRO_FOR_EACH(r,data,e)\ e struct dummy { dummy&amp; operator()(char,int) {return *this;} }; int main() { dummy() BOOST_PP_SEQ_FOR_EACH(MACRO_FOR_EACH,_,SOME_SEQUENCE); return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9633 Trac 1.4.3 Steven Watanabe Mon, 10 Mar 2014 23:06:51 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9633#comment:1 https://svn.boost.org/trac10/ticket/9633#comment:1 <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">invalid</span> </li> </ul> <p> This is not a valid use of BOOST_PP_SEQ_CAT. Gcc is correct to diagnose it. The errors that you are getting are a direct result of the documented behavior of BOOST_PP_SEQ_CAT. </p> Ticket