プリプロセッサ
提供: cppreference.com
< cpp
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
プリプロセッサは。コンパイルが開始される前、翻訳の四段階目に実行されます。プリプロセスの結果は、実際のコンパイラに渡される単一のファイルとなります。
[編集]ディレクティブ
プリプロセッサディレクティブは、プリプロセッサの動作を制御します。各ディレクティブは1行を占有し、次のフォーマットを持つ
#
文字- 命令となる識別子(
define
、undef
、include
、if
、ifdef
、ifndef
、else
、elif
、endif
、line
、error
、warning
、pragma
)|preprocessing instruction (one ofdefine
,undef
,include
,if
,ifdef
,ifndef
,else
,elif
,endif
,line
,error
,warning
,pragma
)}} - 引数(命令によって異なります)
- 改行
ヌル指令(
#
改行が続く)と、許可された効果はありませんされている.Original:
The null directive (
#
followed by a line break) is allowed and has no effect.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集]機能
プリプロセッサは、ソース·ファイル変換機能を備えています
- ソースファイルの一部分を条件付きで有効にする、または無効にする(
#if
、#ifdef
、#ifndef
、#else
、#elif
と#endif
を使用) - ソースファイル中の識別子を任意のテキストに置換する(
#define
と#undef
を用いる) - 引数に渡した字句をを連結する(演算子
##
を用いる) - 引数に渡した字句を文字列リテラル化する(演算子
#
を用いる) - 他のファイルを取り込む(
#include
ディレクティブを用いる。C++17より__has_includeで確認できる) - エラーを出し、コンパイルを途中で停止する(
#error
ディレクティブを用いる)
プリプロセッサの次の側面を制御することができる
Original:
The following aspects of the preprocessor can be controlled:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- 実装定義動作(ディレクティブ
#pragma
を用いる) - ファイル名および行情報(ディレクティブ
#line
を用いる)