#warning Directive

This page was translated by a robot.

The #warningdirective is used to issue compiler warnings. These can be useful, for example, to help other programmers troubleshoot when certain conditions are not met. For example, the following line of code gives a warning on the author's system:


warning: #warning "Software may be fast"
#if __APPLE__
  #warning "Software may be fast"
#endif

Details

The #warningdirective is the direct equivalent of the #errordirective . However, while the #errordirective aborts the compilation, a warning is only issued, but ultimately ignored by the compiler in the hope that everything is fine.

The double quotes and trailing characters " "are a common convention to stay consistent with different compilers. While some preprocessors accept the entire line of code as a warning, others allow the #warningdirective to have only one argument, which is indicated by the quote and trailing characters.

The #warningdirective does not evaluate anything. Even predefined macros such as __LINE__are not processed, but output directly.