#error的用法
#error用于生成一个编译错误的消息
用法:
#error message
message不需要双引号包围
#error编译指示字用于自定义程序员特有的编译错误消息
类似的,#warning用于生成编译警告,用法与#error用法一样
如果出现#error错误信息或者其他错误信息,就无发生成最终的可执行程序
#error是一种预编译器指示字
#error可用于提示编译条件是否满足
#ifndef __cplusplus
#error This file c++
#endif
#line的用法
一般用于多个程序员编写一个项目程序,查找谁的程序的BUG的问题
#line用于强制指定新的行号和编译文件名,并对源程序的代码重新编号
用法:
#line number filename
filename可省略
#line编译指示字的本质是重定义__LINE和__FILE__
#include <stdio.h>
// The code section is written by A.
// Begin
#line 1 "a.c"
// End xiaoming
// The code section is written by B.
// Begin
#line 1 "b.c"
// End xiaowang
// The code section is written by Delphi.
// Begin xiaofei
#line 1 "delphi_tang.c"
int main()
{
printf("%s : %d\n", __FILE__, __LINE__);
printf("%s : %d\n", __FILE__, __LINE__);
return 0;
}
// End