C preprocessor: Difference between revisions

Content deleted Content added
OAbot (talk | contribs)
m Open access bot: url-access updated in citation with #oabot.
No edit summary
Line 43:
* <code>#warning</code>
* <code>#pragma</code>
* <code>defined</code> (follows a conditional directive; not actually a directive, but rather an operator)
* <code>#__has_include</code>
* <code>#__has_cpp_attribute</code> (C++ only)
Line 70:
* <code>#pragma</code>
{{div col end}}
 
C# does not use a preprocessor to handle these directives, and thus they are not handled or removed by a preprocessor, but rather directly read by the C# compiler as a feature of the language.
 
=== Objective-C ===
Line 242 ⟶ 244:
</syntaxhighlight>
 
===Token stringificationOperators===
The preprocessor is capable of interpreting operators and evaluating very basic expressions, such as integer constants, arithmetic operators, comparison operators, logical operators, bitwise operations, the <code>defined</code> operator, and the <code>#</code> stringificafion operator. This allows the preprocessor to make evaluations such as:
<syntaxhighlight lang="cpp">
#if X == 10 // if X equals 10, the preprocessor sees #if 10 == 10
</syntaxhighlight>
 
====Defined operator====
While the '''defined operator''', denoted by <code>defined</code> is not a directive in its own right, if it is read within a directive, it is interpreted by the preprocessor and determines whether a macro has been defined.
 
The following are both accepted ways of invoking the <code>defined</code> operator.
<syntaxhighlight lang="cpp">
#if defined(MY_MACRO)
#if defined MY_MACRO
</syntaxhighlight>
 
====Token stringification operator====
The '''stringification operator''' (a.k.a. stringizing operator), denoted by <code>#</code> converts a token into a [[string literal]], escaping any quotes or backslashes as needed. For definition: