Objective-C preprocessingProgram parsing, IntroductionPreprocessingThe usage of statements in the program,PreprocessingProgram Statements are marked with #), including # define statements, # import statements, and Conditional compilation.Objective-c preprocessing, Objective-c program design, objective-c program compilation,PreprocessingProgram Statement.
# Define statement
1. More advanced definition types
Assign an expression and anything to the symbol name. For example:
The following is the reference content: # define TWO_PI 2*3.141592654, # define AND & Pre-processing program hypothesis definition is included in a row of the program. If the second line is required, the last character of the previous line must be the backslash (\). For example:
Reference content: # define IS_LEAP_YEAR (y) y % 4 = 0 & y0! = 0 \ | y @ 0 = 0 can contain parameters. Predefined definition) is usually called a macro ".
2. # Operators
If a # is placed before the macro parameter in the macro definition, the preprocessing program creates a C-style constant string based on the macro parameter when calling the macro. For example:
The following references: # define str (x) # x str (testing) -- "testing" str ("hello") -- "\" hello "\" 3, # Operator
Used to link two tokens. Is the macro parameter name. The Preprocessing Program uses the actual parameters provided when the macro is called, and creates a single tag Based on the parameter and the tag after # Or before. For example:
The reference content is as follows:/***** desteps.com * 2011-8-15 *****/# define printx (n) printf ("% I \ n", x # n ); printx (20) -- printf ("% I \ n", x20); # import Statement
. H-> header file or include file ).
Set a set of # import statements and input them to an independent file of xxx. h. If necessary, run the Preprocessing Program command:
- # Import "xxx. h ".
- # Import <……> As a result, the Preprocessing Program only searches for contained files in the special "system" header file directory. The current directory is not searched.
- # Import "...... "The Preprocessing Program is in one or more file directories.
Conditional compilation
It is usually used to create programs that can be compiled and run on different computer systems. It is often used to switch various statements in the program.
1. # ifdef, # endif, # else, And # ifndef statements
Port Data from one computer system to another.
2. # if and # elif Preprocessing Program Statements
Non-zero expression results -- all subsequent rows until # else, # elif, or # endif; otherwise, they are skipped.
Special Operator: # define (name) can also be used in # if statements.
3. # undef statement
Make some defined names undefined.
Summary: DetailsObjective-C preprocessingThe content of the program has been introduced. I hope this article will help you.