Master haomeng is devoted to his contribution and respects the author's Labor achievements. Do not repost them.
If the article is helpful to you, you are welcome to donate to the author, support haomeng master, the amount of donation is free, focusing on your mind ^_^
I want to donate: Click to donate
Cocos2d-X source code download: point I send
Preprocessing provides some tools that make it easier to develop, read, and modify programs,
It is also easy to transplant programs to different systems.
You can also use the Preprocessing Program to customize the objective-C language to adapt to the programming of a specific application or your own programming style.
The Preprocessing Program is part of the objective-C compilation process and can identify specific statements distributed in the program.
The Preprocessing Program uses the # MARK. This sign must be the first non-space character in a line.
# Define statement:
# One of the basic purposes of the define statement is to specify a program constant for the symbol name.
The predefined name is not a variable. Therefore, it cannot be assigned a value unless the result of replacing the specified value is actually a variable.
# Define statements are often placed at the beginning of the program, but # After the import or include statements.
The predefined name and variable behavior are different: there is no such statement as a local definition.
All pre-defined names are in uppercase, which makes it easy to distinguish whether a name is a variable name, an object name, a class name, or a pre-defined name.
In fact, when a pre-defined name appears, the Preprocessing Program performs text replacement,
This explains why the # define statement cannot be ended by a semicolon.
Note: redefining the (# define and &) behavior of the underlying language syntax is usually not a good programming habit,
It is not easy for others to understand your code.
If the second line is required, the last character in the previous line must be a backslash. \
Note: when defining a parameter name, spaces are not allowed before the left brackets of the predefined name and parameter list.
Parameters must be enclosed in parentheses.
# Define square (x )*(*))
# Import Statement:
The Preprocessing Program allows you to collect all definitions into a single file and then use the # Import Statement to include them in the program.
This mainly distinguishes between "" and <>. "" Is a local path query, <> is a system path query.
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.
# Ifdef, # endif, # else, # ifndef and # UNDEF are the same as those in C.
# Ifdef debug
# If defined (Debug)
The role is the same.
# UNDEF is used to remove the defined name
Objective-C magic path [13-Preprocessing Program]