g++ -c gives error for the following code: class listitem { public: int m_i; listitem *m_next; void setint( int i ); };
#define ITERATE(item,whattocall,value) \ do \ { \ item->##whattocall(value); \ item=item->m_next; \ } while( 0 !=item ) void listitem::setint( int p_i ) { m_i= p_i; } int main( int argc, char **argv ) { listitem *li; return 1; ITERATE( li,setint,100); } compiling it with -E, the preprocessed code is correct, but an error is repotred. macro.cc:24:1: error: pasting "->" and "setint" does not give a valid preprocessing token make: *** [macro.o] Error 1 the code above has no any purpose except to reproduce the error. -- Summary: token pasting does not seem to work Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: compi at freemail dot hu CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23748