Information Technology Reference
In-Depth Information
What Are Preprocessor Directives?
The source code specifies the definition of a program. The preprocessor directives instruct the
compiler how to treat the source code. For example, under certain conditions, you might want
the compiler to ignore portions of the code, and under other conditions, you might want that
code compiled. The preprocessor directives give you those options and several others.
In C and C++ there is an actual preprocessor phase, in which the preprocessor goes
through the source code and prepares an output stream of text that will be processed by the
subsequent compilation phase. In C# there is no actual preprocessor. The “preprocessor”
directives are handled by the compiler. The term, however, remains.
General Rules
Some of the most important syntactic rules for preprocessor directives are the following:
￿
Preprocessor directives must be on lines separate from C# code.
￿
Unlike C# statements, preprocessor directives are not terminated with a semicolon.
Every line containing a preprocessor directive must start with the # character.
-
￿
There can be space between the # sign and the directive.
There can be space before the # .
-
￿
End-of-line comments are allowed.
￿
Delimited comments are not allowed in a preprocessor directive line.
Search WWH ::




Custom Search