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.
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.
I do not know about a #pragma, but #error should do what you want:
#error Failing compilation
Will terminate compilation with the error message "Failing compilation"
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$