The Wayback Machine - https://web.archive.org/web/20120805004727/http://ru.cppreference.com:80/w/cpp/preprocessor
Пространства имён
��арианты
Действия

Команды препроцессора

Материал из cppreference.com
< cpp
 
 
C++ language
General topics
Preprocessor
Comments
Keywords
ASCII chart
Escape sequences
History of C++
Flow control
Conditional execution statements
Iteration statements
Jump statements
Functions
function declaration
lambda function declaration
function template
inline specifier
exception specifications (устарело)
noexcept specifier (C++11)
Exceptions
Namespaces
Types
decltype specifier (C++11)
Specifiers
cv specifiers
storage duration specifiers
constexpr specifier (C++11)
auto specifier (C++11)
alignas specifier (C++11)
Literals
Expressions
alternative representations
Utilities
Types
typedef declaration
type alias declaration (C++11)
attributes (C++11)
Casts
implicit conversions
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-style and functional cast
Memory allocation
Classes
Class-specific function properties
Special member functions
Templates
class template
function template
template specialization
parameter packs (C++11)
Miscellaneous
Inline assembly
 
 

Препроцессор стартует до начала компиляции. Команды, отданные препроцессору, позволяют программисту определить переменные, совершить замену текста и проверить простые условия.

[править] Препроцессорные директивы

Директивы управляют поведением препроцессора. Каждая директива занимает одну строку и имеет следующий формат:

  • символ #
  • препроцессорная инструкция (одна из define, undef, include, if, ifdef, ifndef, else, elif, endif, line, error, warning, pragma)
  • аргументы (в зависимости от инструкции)

Разрешена пустая директива (символ #, за которым следует перевод строки).

[править] Команды

# and ## манипулирование строками
#define определение констант
#error отображение текста ошибок
#if, #ifdef, #ifndef, #else, #elif и #endif операторы условия
#include вставка содержимого другого файла
#line добавление информации о файле и строке
#pragma осуществление конкретных команд
#undef удаление объявленных переменных
Predefined preprocessor variables различные переменные препроцессора