error的用法
·#error用于生成一个编译错误消息
·用法
#error message
message不需要用双引号包围
#error编译指示字用于自定义程序员特有的编译错误消息
类似的,#warning用于生成编译警告。
#error是一种预编译器指示字
#error可用于提示编译条件是否满足
例子23-2:
#include "stdio.h"
define product 6
void f()
{
#if(product == 1)
printf("low!\n");
#elif(product == 2)
printf("middle!\n");
#elif(product == 3)
printf("high!\n");
#else
#error the productis not defined!
#warning the productis not defined!
#endif
}
int main()
{
f();
#if(product == 1)
printf("111!\n");
#elif(product == 2)
printf("222!\n");
#elif(product == 3)
printf("3333!\n");
#endif
}
小结:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。