Opened 9 years ago

Closed 9 years ago

#9633 closed Bugs (invalid)

BOOST_PP_SEQ_CAT with a sequence of comma separated pairs fails with gcc

Reported by: albertembedded@… Owned by: No-Maintainer
Milestone: To Be Determined Component: preprocessor
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

Hi,

Code with problem :

#include <boost\preprocessor\seq\cat.hpp>

#define SOME_SEQUENCE (('a',1)) (('b',2)) (('c',3)) (('d',4)) (('e',5))

struct dummy
{
    dummy& operator()(char,int) {return *this;}
};

int main()
{
    dummy() BOOST_PP_SEQ_CAT(SOME_SEQUENCE);

    return 0;
}

Following code compiles with Visual 2010. (generates dummy() ('a',1)('b',2)('c',3)('d',4)('e',5);)

With gcc, it does not compil.

I have a collection of compilation error :

main.cpp:3:30: error: pasting ")" and "(" does not give a valid preprocessing token

preprocessor\seq\cat.hpp:35:37: note: in definition of macro 'BOOST_PP_SEQ_CAT_O_I'

preprocessor/seq/fold_left.hpp:555:144: note: in expansion of macro 'BOOST_PP_SEQ_CAT_O'

and so on

By gcc, I mean TDM MinGW32 (from tdm-gcc-4.8.1-3.exe)

Tried with following options :

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

Notice that following code compiles fine which can be used as a workaround :

Code compiling :

#include <boost\preprocessor\seq\for_each.hpp>

#define SOME_SEQUENCE (('a',1)) (('b',2)) (('c',3)) (('d',4)) (('e',5))

#define MACRO_FOR_EACH(r,data,e)\
    e

struct dummy
{
    dummy& operator()(char,int) {return *this;}
};

int main()
{
    dummy() BOOST_PP_SEQ_FOR_EACH(MACRO_FOR_EACH,_,SOME_SEQUENCE);

    return 0;
}

Change History (1)

comment:1 by Steven Watanabe, 9 years ago

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.