1)
# If defined xxx_xxx
# Endif
It is conditional compilation. It is used based on whether you have defined the xxx_xxx macro. Code .
In general, the outermost layer of the. h file
# If! Defined xxx_xxx
# Define xxx_xxx
# Endif
To prevent this. h header file from being repeatedly included.
# UNDEF is undefined. # ifndef is short for if not defined.
2)
# Error xxxx
Is used to generate the error message XXXX during compilation, which is generally used in preprocessing;
Example:
# If! Defined (_ cplusplus)
# Error C ++ compiler required.
# Endif
3)
The global variable extern is equivalent to the public variable in C #.
4)
_ Cdecl and _ stdcall are two types of C ++ function call rules.
_ Cdecl:
Argument-passing order
Right to left
Stack-Maintenance Responsibility
Calling function pops the arguments from the stack
Name-decoration Convention
Underscore character (_) is prefixed to names, cannot t when exporting _ cdecl functions that use C linkage.
Case-translation Convention
No case Translation
_ Stdcall:
Argument-passing order
Right to left.
Argument-passing Convention
By value, unless a pointer or reference type is passed.
Stack-Maintenance Responsibility
Called function pops its own arguments from the stack.
Name-decoration Convention
An underscore (_) is prefixed to the name. the name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. therefore, the function declared as int func (int A, double B) is decorated as follows: _ FUNC @ 12
Case-translation Convention
None
5)
# Pragma pack ([show] | [push | Pop] [, identifier], n)
This is used to specify the class and structure memory alignment;
This is a bit more. You can check the memory on the Internet;
6)
_ Declspec (dllimport) declarator
_ Declspec (dllexport) declarator
These two are related to the DLL and declare the functions, classes, or data that can be output and input from the DLL file;
7)
# Pragma once
Yes. This file can only be included once during compilation;
Similar
# If define
8)
Disable message
I have never seen it before ....
9)
_ Int64
It is a 64-bit integer type to prevent 32-bit int from being used when it is not enough;
10)
# Pragma code_seg ([[{push | Pop},] [identifier,] ["segment-name" [, "segment-class"])
Is used to define the segment in which the function is placed in the OBJ file.
---------------------------------------------------
# If defined macro_name
And
# Ifdef macro_name is slightly different.
For example, our company encourages writing the first one, because it can write like this:
# If defined (macro_name) & defined (macro_name)
This # error allows you to manually generate a compilation error during compilation. More accurately, it is used for preprocessing.
# If! Defined (_ cplusplus)
# Error C ++ compiler required.
# Endif
This means that if yourProgramIf it is not c ++, for example, C, an error will be reported. The error message is determined by the user.
# Pragma once is basically the same as the previous one.