GCC #pragma停止编译 [英] GCC #pragma to stop compilation
本文介绍了GCC #pragma停止编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有GCC pragma指令会停止,暂停或终止编译过程?
我使用gcc 4.1,但希望编译指示可用gcc 3.x版本也可以。
您可能想要 #error
: edd @ ron:/ tmp $ g ++ -Wall -DGoOn -o stopthis stopthis.cpp
edd @ ron :/ tmp $ ./stopthis
Hello,world
edd @ ron:/ tmp $ g ++ -Wall -o stopthis stopthis.cpp
stopthis.cpp:7:6:error:#error我有足够的
edd @ ron:/ tmp $ cat stopthis.cpp
#include< iostream>
int main(void){
std :: cout<< 你好,world \\\
;
#ifndef GoOn
#error我有足够的
#endif
return 0;
}
edd @ ron:/ tmp
Is there a GCC pragma directive that will stop,halt, or abort the compilation process?
I am using gcc 4.1 but would want the pragma to be available on gcc 3.x versions also.
解决方案
You probably want #error
:
edd@ron:/tmp$ g++ -Wall -DGoOn -o stopthis stopthis.cpp
edd@ron:/tmp$ ./stopthis
Hello, world
edd@ron:/tmp$ g++ -Wall -o stopthis stopthis.cpp
stopthis.cpp:7:6: error: #error I had enough
edd@ron:/tmp$ cat stopthis.cpp
#include <iostream>
int main(void) {
std::cout << "Hello, world\n";
#ifndef GoOn
#error I had enough
#endif
return 0;
}
edd@ron:/tmp$
这篇关于GCC #pragma停止编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文