Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to add a line to a header that will display a compile error if a certain compiler switch is not set?
Posted

1 solution

yes possible. you can do this like:

XML
$ cat 1.c
#include <stdio.h>

#ifndef TEST
#error err
#endif

int main() {
 return 0;
}


error if no TEST define
$ gcc 1.c
1.c:4:2: error: #error err


clear if -D TEST
$ gcc 1.c -D TEST
 
Share this answer
 
Comments
Vedat Ozan Oner 12-Feb-14 17:22pm    
I'm thinking that I might have misunderstood the question. is my answer a solution for your question?
Sergey Alexandrovich Kryukov 12-Feb-14 18:09pm    
I cannot imagine that OP could mean something else, not covered by this answer. It should be the answer, recommended to be accepted formally. My 5.
—SA
Vedat Ozan Oner 12-Feb-14 18:38pm    
else my answer would be no :) thanks by the way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900