c_programming_language/c_modern_approach/Preprocessor/error.c

21 lines
502 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
// #define DEBUG 1
int main() {
#ifdef DEBUG
printf("All good, DEBUG is initialized");
#else
#error Debug is not initiated!
#endif
return 0;
}
// #error identifier blocks code compilation if compiler reached it.
// For example code above will not compile if DEBUG is not initiated.
//
// error.c: In function main:
// error.c:8:2: error: #error Debug is not initiated!
// 8 | #error Debug is not initiated!
// | ^~~~~
// make: *** [Makefile:14: main] Error 1