#include <stdio.h>
#define AMP_Assert( expr ) if( !(expr) ) { \
printf("** Assertion failed: \"" #expr "\" at %s:%d %s()\n", __FILE__, __LINE__, __FUNCTION__);\
}
int main(int argc, const char* argv[])
{
int a = 1;
AMP_Assert(a % 8 == 0);
return 0;
}
以下警告将在gcc和msvc中发生
macrotest.cpp: In function ‘int main(int, const char**)’:
macrotest.cpp:4:95: warning: unknown conversion type character ‘ ’ in format [-Wformat=]
如何摆脱这种警告?让宏替换'%'正确替换。