名前空間
変種
操作

エラー指令

提供: cppreference.com

指定されたエラーメッセージを表示し、プログラムを ill-formed にします。

目次

[編集]構文

#errorerror_message

[編集]説明

#error 指令に遭遇した後、処理系は診断メッセージ error_message を表示し、プログラムを ill-formed にします (コンパイルを停止します)。

error_message は複数の単語から構成することができます。 引用符で囲む必要はありません。

[編集]

#if __STDC__ != 1# error "Not a standard compliant compiler"#endif   #include <stdio.h>int main (void){printf("The compiler used conforms to the ISO C Standard !!");}

出力例:

The compiler used conforms to the ISO C Standard !!

[編集]参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 6.10.5 Error directive (p: 174)
  • C99 standard (ISO/IEC 9899:1999):
  • 6.10.5 Error directive (p: 159)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 3.8.5 Error directive

[編集]関連項目

エラー指令C++リファレンス
close