Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC #pragma to stop compilation

Tags:

gcc

Is there a GCC pragma directive that will stop, halt, or abort the compilation process?

I am using GCC 4.1, but I would want the pragma to be available in GCC 3.x versions also.

like image 945
Sean A.O. Harney Avatar asked Jan 23 '10 22:01

Sean A.O. Harney


People also ask

What GCC means?

The Gulf Cooperation Council (GCC) was established by an agreement concluded on 25 May 1981 in Riyadh, Saudi Arabia among Bahrain, Kuwait, Oman, Qatar, Saudi Arabia and UAE in view of their special relations, geographic proximity, similar political systems based on Islamic beliefs, joint destiny and common objectives.

Which countries fall under GCC?

Gulf Cooperation Council (GCC), political and economic alliance of six Middle Eastern countries—Saudi Arabia, Kuwait, the United Arab Emirates, Qatar, Bahrain, and Oman.

Is UAE a GCC country?

List of six Arab GCC (or AGCC) countries (Gulf countries), citizen nationalities, nations, or member states is Bahrain, Kuwait, Oman, Qatar, Saudi Arabia, UAE. Yemen and Iran are Muslim countries but not GCC members.


2 Answers

You probably want #error:

$ cd /tmp $ g++ -Wall -DGoOn -o stopthis stopthis.cpp $ ./stopthis  Hello, world  $ g++ -Wall -o stopthis stopthis.cpp  stopthis.cpp:7:6: error: #error I had enough 

File stopthis.cpp

#include <iostream>  int main(void) {   std::cout << "Hello, world\n";   #ifndef GoOn     #error I had enough   #endif   return 0; } 
like image 103
Dirk Eddelbuettel Avatar answered Sep 26 '22 02:09

Dirk Eddelbuettel


I do not know about a #pragma, but #error should do what you want:

#error Failing compilation 

It will terminate compilation with the error message "Failing compilation".

like image 41
Michael Avatar answered Sep 23 '22 02:09

Michael