可以请人给我解释一下我究竟做错了什么,我收到文件的错误意外结束,也缺少函数头,在此先感谢调试错误
static char debug[256];
#define DBGPRINT(...) {sprintf_s(debug, 256, __VA_ARGS__); OutputDebugStringA(debug);}
#define CHECK_READ(status, str) while(0){ \
if(0 == status){ \
DBGPRINT("Message %s\n", str); \
return 0; \
} \
}
int main(){
char* str = "hello world";
status = 0;
CHECK_READ(status, str);
return 0;
}
错误:
Error line 7 error C2447: '{' : missing function header (old-style formal list?)
Error line 11 error C2447: '{' : missing function header (old-style formal list?)
Error line 15 error C2017: illegal escape sequence
Error line 19 fatal error C1004: unexpected end-of-file found
尽可能不要在C++中使用宏和原始char *字符串。 –
@dark_charlie:在特定情况下,用同样紧凑的东西来替换宏将会非常复杂。但是当然,char *字符串是邪恶的。 – Vlad
@Vlad:你的宏是NOOP。它可以很好地替换为空行。 – Mat