#error 编译 gcc

 

在程序中使用#error可以在编译的时候强制产生一个错误及提示

例如:

#ifndef SIGSEGV
#error "SIGNAL.H does not define SIGSEGV; running this program WILL cause a core dump/crash!"
#endif

 

例如:

int main()
{

    #error "this is just used to test!"
    return 0;
}

[root@lihao /]# make
cc test.c

test.c:6:2: #error "this is just used to test!"
make: *** [test] Error 1

posted @ 2013-04-02 14:06  only_eVonne  阅读(490)  评论(0编辑  收藏  举报