#include<stdio.h>
#define PRINT (format,...) printf(#format,##__VA_ARGS__)
int main(void)
{
PRINT(num = %d\n, 520);
PRINT(Hello world\n);
return 0;
}
代码这样 报错是这样
2 45 D:\yxlc\未解决\可变参数宏.cpp [Warning] __VA_ARGS__ can only appear in the expansion of a C99 variadic macro
2 35 D:\yxlc\未解决\可变参数宏.cpp [Error] stray '#' in program
6 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
2 42 D:\yxlc\未解决\可变参数宏.cpp [Error] pasting "," and "__VA_ARGS__" does not give a valid preprocessing token
6 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
6 5 D:\yxlc\未解决\可变参数宏.cpp [Error] stray '\' in program
2 35 D:\yxlc\未解决\可变参数宏.cpp [Error] stray '#' in program
7 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
2 42 D:\yxlc\未解决\可变参数宏.cpp [Error] pasting "," and "__VA_ARGS__" does not give a valid preprocessing token
7 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
7 5 D:\yxlc\未解决\可变参数宏.cpp [Error] stray '\' in program
D:\yxlc\未解决\可变参数宏.cpp In function 'int main()':
2 16 D:\yxlc\未解决\可变参数宏.cpp [Error] 'format' was not declared in this scope
6 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
2 23 D:\yxlc\未解决\可变参数宏.cpp [Error] expected primary-expression before '...' token
6 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
2 23 D:\yxlc\未解决\可变参数宏.cpp [Error] expected ')' before '...' token
6 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
2 23 D:\yxlc\未解决\可变参数宏.cpp [Error] expected primary-expression before '...' token
7 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
2 23 D:\yxlc\未解决\可变参数宏.cpp [Error] expected ')' before '...' token
7 5 D:\yxlc\未解决\可变参数宏.cpp [Note] in expansion of macro 'PRINT'
|