The Wayback Machine - https://web.archive.org/web/20180311162637/http://ja.cppreference.com:80/w/cpp/preprocessor
名前空間
変種
操作

プリプロセッサ

提供: cppreference.com
< cpp

 
 
C++言語
一般的なトピック
プリプロセッサ
コメント
フロー制御
条件付き実行文
繰り返し文 (ループ)
ジャンプ文
関数
関数宣言
ラムダ関数宣言
inline 指定子
例外指定(廃止予定)
noexcept 指定子(C++11)
例外
名前空間
指定子
decltype(C++11)
auto(C++11)
alignas(C++11)
記憶域期間指定子
初期化
代替表現
リテラル
ブーリアン - 整数 - 浮動小数点
文字 - 文字列 - nullptr(C++11)
ユーザ定義(C++11)
ユーティリティ
アトリビュート(C++11)
typedef 宣言
型エイリアス宣言(C++11)
キャスト
暗黙の変換 - 明示的な変換
static_cast - dynamic_cast
const_cast - reinterpret_cast
メモリ確保
クラス
クラス固有の関数特性
特別なメンバ関数
テンプレート
その他
 
 

プリプロセッサは。コンパイルが開始される前、翻訳の四段階目に実行されます。プリプロセスの結果は、実際のコンパイラに渡される単一のファイルとなります。

[編集]ディレクティブ

プリプロセッサディレクティブは、プリプロセッサの動作を制御します。各ディレクティブは1行を占有し、次のフォーマットを持つ

  • #文字
  • 命令となる識別子(defineundefincludeififdefifndefelseelifendiflineerrorwarningpragma)|preprocessing instruction (one of define, 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.

[編集]機能

プリプロセッサは、ソース·ファイル変換機能を備えています

  • ソースファイルの一部分を条件付きで有効にする、または無効にする(#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.
close