-------iOS training, Android training, Java training, and looking forward to communicating with you! ----------
A Compiling pre-processing directives
Run , compile-and- link , source code, compile preprocessing
Compile pre-processing directives: parsing instructions before compiling
Feature: All compilation preprocessing directives start with #
All compilation preprocessing directives do not have semicolons
Two Macro definition
1. macro definition without parameters: #define Macro Name Value
(1) where the macro name is identified at the time of precompilation, the value following the macro name will be replaced
Note: Macro names in comments are not replaced
The macro name that appears in the string is not replaced
(2) Naming conventions for macro names: All caps, with multiple words separated by underscores
2. macro definition with parameters: #define Macro name ( argument list ) expression
(1) The parameters in the argument list are substituted into the expression, and then replace the place where the macro name appears
Note: There is no data type in the parameter list.
Do not add a space between the macro name and the parentheses
(2) The difference between a macro definition with a parameter and a function:
function has the call process, will open up storage space, the cost is larger
The macro is just a replacement operation
(3) To cancel the definition of a macro #undef
Own understanding of:
1. When doing a problem, remember that the macro is just a replacement operation
2. When you define a macro, enclose all occurrences of the parameter and the result of the operation.
3. Do not use the self-increment and compound assignment operators in parameters
Three Conditional compilation: Compile a piece of code when the condition is met at compile time
1. format: #if start #elif #else #endif End
Features: (1) Conditional compilation conditions can only be made up of macro definitions and constants, cannot appear variable
(2) Judgment at compile time
Usage scenarios:
1. #indef Macro Name
If a macro is defined, execute the statement here
#endif
2. #ifndef
If you do not define a macro, execute the statement here
#endif
Four. Static and extern
1. The role of local variables
Static: (1) extends the life cycle of a variable: from the start of the first execution until the file exits
(2) The defined line of code executes only once
(3) does not change the scope of the variable
extern: placed inside a function, just a declaration of a global variable
2. The role of global variables
Internal variables: Variables that can only be accessed in this file
External variables: Variables that can be accessed in all files
Static: Declares or defines an internal variable
extern: Declaring or defining an external variable
3. Effects on functions
Intrinsic functions: Functions that can only be used in this file
External functions: Functions that can be used in other files, by default all functions are external functions
Static: Declares or defines an intrinsic function
extern: Complete declaration or definition of an external function
Dark Horse Programmer-C Learning Note-compiling pre-processing instructions