The Scope of Preprocessor Directives
|Top Previous Next|
Conditional constructs #if, #ifdef, and #ifndef must be contained entirely within a single file.
The scope of the #define directive is limited to a header file in which this directive resides plus all files that include this file with the (#) include, #includeb, or (#)includepp directives.
A #define directive placed in a source file is only visible in this source file.
Scope of #define directives placed in your source and header files
Like variable defines or declarations, preprocessor identifiers created with the #define directive are visible from the line where they are defined onwards.
Unlike variables, the scope of a preprocessor identifiers always extends to the bottom of a file (or to the bottom of all files that include this file).
There are no local scopes and sub-scopes for preprocessor definitions. Here is a code example:
Scope of preprocessor identifiers defined in the Customize Project dialog
Global preprocessor identifiers (from the Customize Project dialog) are visible everywhere in your project.