simplecpp
simplecpp copied to clipboard
token pasting and empty tokens
// test.h
#define SIMPLE(T, NAME) \
T NAME;
#define ADVANCED(T, PREFIX, NAME, EXTENSION) \
SIMPLE(T, PREFIX##NAME##EXTENSION)
ADVANCED(int, , foo, )
cppcheck -E test.h
Checking test.h ...
[test.h:6]: (error) failed to expand 'ADVANCED', Invalid ## usage when expanding 'ADVANCED'.
cpp test.h
# 1 "test.h"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "test.h"
# 9 "test.h"
int foo;
Same result with 0fe0ab6:
./simplecpp test.h
test.h:6: syntax error: failed to expand 'ADVANCED', Invalid ## usage when expanding 'ADVANCED': Unexpected token ',foo'