[ Web Proxy ]
URL:
Viewing: https://de.cppreference.com/cpp/preprocessor/conditional [Back]  [Original]

Conditional inclusion cppreference.com
cppreference.com
Namensrume
Varianten

Conditional inclusion

Aus cppreference.com

<metanoindex/>

 
 
Sprache C++
Allgemeine Themen
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Flusskontrolle
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bedingte Ausfhrung Aussagen
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Iterationsanweisungen
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Gehe Aussagen
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktion Erklrung
Lambda-Funktion Erklrung
Funktions-Template
inline-Spezifizierer
Exception-Spezifikationen (veraltet)
noexcept Spezifizierer (C++11)
Ausnahmen
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
Specifiers
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv Planer
Lagerdauer Planer
constexpr Spezifizierer (C++11)
auto Spezifizierer (C++11)
alignas Spezifizierer (C++11)
Initialisierung
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literale
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressions
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
alternative Darstellungen
Utilities
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
Typ Aliasdeklaration (C++11)
Attribute (C++11)
Wirft
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
impliziten Konvertierungen
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-Stil und funktionale Besetzung
Speicherzuweisung
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Class-spezifische Funktion Eigenschaften
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
explizit (C++11)
statisch
Besondere Member-Funktionen
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Templates
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Klassen-Template
Funktions-Template
Template-Spezialisierung
Parameter Packs (C++11)
Verschiedenes
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Inline Montage
 
 
Der Prprozessor untersttzt die bedingte Kompilierung von Teilen der Quelldatei. Dieses Verhalten wird durch #if, #else, #elif, #ifdef, #ifndef und #endif Richtlinien gesteuert .
Original:
The preprocessor supports conditional compilation of parts of source file. This behavior is controlled by #if, #else, #elif, #ifdef, #ifndef and #endif directives.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Syntax

#if expression
#elif expression
#ifdef expression
#ifndef expression
#else expression
#endif expression

Erklrung

Die bedingte Vorverarbeitung Block beginnt mit #if, #ifdef oder #ifndef Richtlinie, dann schliet gegebenenfalls eine beliebige Anzahl von #elif Richtlinien, dann schliet gegebenenfalls hchstens eine #else Richtlinie und ist mit #endif Richtlinie beendet. Alle inneren bedingte Vorverarbeitung Blcke werden getrennt verarbeitet .
Original:
The conditional preprocessing block starts with #if, #ifdef or #ifndef directive, then optionally includes any number of #elif directives, then optionally includes at most one #else directive and is terminated with #endif directive. Any inner conditional preprocessing blocks are processed separately.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Jeder #if, #elif, #else, #ifdef und #ifndef Richtlinien Steuercode Block bis zum ersten #elif, #else, #endif Richtlinie ohne Zugehrigkeit zu einem inneren bedingte Vorverarbeitung Blcken .
Original:
Each of #if, #elif, #else, #ifdef and #ifndef directives control code block until first #elif, #else, #endif directive not belonging to any inner conditional preprocessing blocks.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#if, #ifdef und #ifndef Richtlinien testen Sie die angegebene Bedingung (siehe unten), und wenn es den Wert true ergibt, stellt die kontrollierte Code-Block. In diesem Fall nachfolgenden #else und #elif Richtlinien werden ignoriert. Andernfalls, wenn die angegebene Bedingung falsch ist, wird die kontrollierte Codeblock bersprungen und die nachfolgende #else oder #elif Richtlinie (falls vorhanden) verarbeitet wird. Im ersteren Fall wird der Code-Block durch die Richtlinie #else gesteuert bedingungslos zusammengestellt. Im letzteren Fall wirkt die #elif Richtlinie als ob es #if Richtlinie war: Kontrollen fr den Zustand, kompiliert oder berspringt die kontrollierte Codeblock basierend auf dem Ergebnis, und im letzteren Fall verarbeitet nachfolgenden #elif und #else Richtlinien. Die bedingte Vorverarbeitungsblock wird durch #endif Direktive beendet .
Original:
#if, #ifdef and #ifndef directives test the specified condition (see below) and if it evaluates to true, compiles the controlled code block. In that case subsequent #else and #elif directives are ignored. Otherwise, if the specified condition evaluates false, the controlled code block is skipped and the subsequent #else or #elif directive (if any) is processed. In the former case, the code block controlled by the #else directive is unconditionally compiled. In the latter case, the #elif directive acts as if it was #if directive: checks for condition, compiles or skips the controlled code block based on the result, and in the latter case processes subsequent #elif and #else directives. The conditional preprocessing block is terminated by #endif directive.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Bedingungsauswertung

#if, #elif

Die expression ist ein konstanter Ausdruck mit nur Literale und Kennungen, definiert mit #define Richtlinie. Jeder Bezeichner, die nicht wrtlich, nicht definierten Verwendung #define Richtlinie ausgewertet 0 .
Original:
The expression is a constant expression, using only Literale and identifiers, defined using #define directive. Any identifier, which is not literal, non defined using #define directive, evaluates to 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Der Ausdruck kann unre Operatoren in Form enthalten defined identifier oder defined (identifier) die 1 zurck, wenn die identifier wurde unter Verwendung von #define Richtlinie und 0 anders. Wenn die expression ausgewertet Wert ungleich Null, wird die kontrollierte Codeblock enthalten und bersprungen anders. Wenn eine verwendete Kennung ist keine Konstante, wird es mit 0 ersetzt .
Original:
The expression may contain unary operators in form defined identifier or defined (identifier) which return 1 if the identifier was defined using #define directive and 0 otherwise. If the expression evaluates to nonzero value, the controlled code block is included and skipped otherwise. If any used identifier is not a constant, it is replaced with 0.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#ifdef, #ifndef

Prft, ob die Kennung definiert wurde mit #define Richtlinie .
Original:
Checks if the identifier was defined using #define directive.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#ifdef identifier entspricht im Wesentlichen #if defined( identifier) .
Original:
#ifdef identifier is essentially equivalent to #if defined( identifier).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#ifndef identifier entspricht im Wesentlichen #if !defined( identifier) .
Original:
#ifndef identifier is essentially equivalent to #if !defined( identifier).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Beispiel

#define ABCD 2
#include <iostream>

int main()
{

#ifdef ABCD
    std::cout << "1: yes\n";
#else
    std::cout << "1: no\n";
#endif

#ifndef ABCD
    std::cout << "2: no1\n";
#elif ABCD == 2
    std::cout << "2: yes\n";
#else
    std::cout << "2: no2\n";
#endif

#if !defined(DCBA) && (ABCD < 2*4-3)
    std::cout << "3: yes\n";
#endif
}

Output:

1: yes
2: yes
3: yes

Web Proxy Viewer  |  New URL  |  Original Page