プリプロセッサディレクティブとは?
プリプロセッサディレクティブは、通常ハッシュ記号で始まる命令で、コンパイラ本体がコードを見る前にプリプロセッサが作用します。ディレクティブはファイルをインクルードし、マクロを定義・展開し、条件に基づいてコードのブロックを含めたり外したりします。ソーステキストを変換し、その後コンパイルされる最終的な翻訳単位を生み出します。
なぜ重要か
ディレクティブは実際のコンパイルの前に実行されるため、コンパイラが最終的に見るコードを形作り、それが強力である一方で誤用しやすくもします。ディレクティブが駆動する条件付きコンパイルやマクロは、微妙なビルドの差異の一般的な原因です。
関連ガイド
What Is a Header Guard?A header guard is a preprocessor pattern that ensures a header file is included only once per translation uni…
What Is a Translation Unit?A translation unit is the complete source seen by the compiler after preprocessing one source file, the unit…
What Is a Forward Declaration?A forward declaration tells the compiler a name exists and its type before its full definition, letting code…