[cfe-dev] invalid-token-paste

Shang Yu yusunn at gmail.com
Wed Jul 18 17:58:25 PDT 2012


Hi dear all,
Look at the following code

#include <stdio.h>
#define STR(a,b) a##b
void test()
{
	printf("%s\n" , STR("1","2"));
}
compiled with clang -c test2.cpp will failed with following error:
test2.cpp:9:18: error: pasting formed '"1""2"', an invalid preprocessing token
      [-Winvalid-token-paste]
        printf("%s\n" , STR("1","2"));
                        ^
test2.cpp:6:19: note: expanded from macro 'STR'
#define STR(a,b) a##b
                  ^
1 error generated.
                  ^
the same code will pass compiled with msvc. Any suggestion ? Many thanks !



More information about the cfe-dev mailing list