1\\ C + + macros:
???? (1) # The function is to use the following macro parameters for string operation (stringfication);
???? Eg: #define WARN_IF (EXP)????
???? do{if (EXP)????
???????????????? fprintf (stderr, "Warning:" #EXP "\ n");}???
??????? ? while (0)
???? Wern_if (value = = 0);
???? expanded to :
???? do{
???????? if (value = = 0)
???????? fprintf (stderr, "warning:valude = = 0");
????} while (0);
???? (2) # # Connector ( concatenator ), used to set two of the token ( Mark ) connected to a token, Action object is no longer limited to macro parameters Span style= "font-family: Song body; Background-color:white "> can also be used with
???????? #define DECLARE_HANDLE (name) struct name# #__ {int unused;}; typedef struct name# #__ *name ( The pointer type for redefining the struct name# #__ is name)
???? Declare_handle (HWND);
???? HWND HD;
???? will get a struct pointer ;
???? --------------------------------------
???? Note : where the macro definition has # or ## the Place , macro parameters are not expanded
???? #define A 2;
???? #define PARAM (A) #A # #_;
???? printf ("%s", PARAM (A));
???? Get printf ("%s", A_);???? Compile error
???? macro Parameters A will not be unfolded as expected. 2_????
???? (3) C language predefined macros :
???? __date__
????date that the preprocessing was made ("Mmm dd yyyy"form of string literals)
???? __file__
????string literal representing the current source code file name
???? __line__
????An integer constant representing the line number in the current source code
???? __time__
????source file compilation time, Lattice micro"HH:mm:SS "
???? __FUNCTION__ (__fucn__)
????name of current function?
???? __date__, __time__ Yes build time if rebuild program __date__, __time__ and it changed.
2\\typedef:
???? structint__
???? {
???????? int A;
????};
???? typedefint__* pit;???????? // redefine int__ pointer type to pit
???? typedef int__ it
???? Pit pt = NULL;
???? Pt->a = 1000;
C + + Drip