Preprocessor error messages

suggest change

Compile errors can be generated using the preprocessor. This is useful for a number of reasons some of which include, notifying a user if they are on an unsupported platform or an unsupported compiler.

For example, report an error when the GCC major version is less than 3. In #if, an undefined name is replaced by 0, so this also rejects a compiler that does not define __GNUC__. GCC 3.0.0 defines __GNUC__ as 3, so the condition does not reject it.

#if __GNUC__ < 3
#error "This code requires GCC 3 or later"
#endif

e.g. Return Error if compiling on an Apple computer.

#ifdef __APPLE__
#error "Apple products are not supported in this release"
#endif

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents