如何在eclipse for c中做类似的事情
#ifdef _DEBUG printf("debug mode is on\n");
#elif printf("debug mode is off\n");
我搜索了一下,发现我需要使用ifdeb,但不幸的是它没用
提前谢谢你的帮助
最佳答案
ifdef和elif使用整行作为条件,因此printf被解释为if的一部分。您需要将代码放在单独的行上,并使用“endif”关闭“if”
例如
#ifdef _DEBUG
printf("debug mode is on\n");
#else
printf("debug mode is off\n");
#endif