1
# Ifdef _ XXXX
... Procedure 1...
# Else
Www.2cto.com
... Procedure 2...
# Endif
This indicates that if the identifier _ XXXX has been defined by the # define command, the program segment 1 will be compiled; otherwise, the program segment 2 will be compiled.
2
# Ifndef _ XXXX
... Procedure 1...
# Else
... Procedure 2...
# Endif
# Ifndef is used here, indicating if not def. of course, it is the opposite of # ifdef (if the identifier _ XXXX is not defined, the execution segment 1; otherwise, the execution Segment 2 ).
3
# If constant
... Procedure 1...
# Elif <constant expression 2>
... Procedure 2...
# Elif <constant expression 3>
... Program Section 3...
......
# Else
... Procedure 2...
# Endif
It indicates that if the constant is true (not 0, whatever number, as long as it is not 0), the program segment 1 will be executed; otherwise, the program segment 2 will be executed.
For example:
1.
# If defined (_ PC) & defined (_ SSE)
# Ifdef DEBUG
# Define _ PC_VERIFY_ALIGNMENT __
# Endif
# Ifdef _ PC_VERIFY_ALIGNMENT __
# Define PC_VERIFY_ALIGN_ASSERT (ptr )\
{\
If (INT) ptr) % 16 )! = 0 )\
{\
Debugf (NAME_Critical, TEXT ("Unaligned PC data (0x % X)"), ptr );\
DebugBreak ();\
}\
}
# Else
# Define PC_VERIFY_ALIGN_ASSERT (ptr)
# Endif
# Else
# Define PC_VERIFY_ALIGN_ASSERT (ptr)
# Endif
2.
# Define ABC 3
Main ()
{
# If ABC> 0
Int a = 1;
Printf ("% d \ n", );
# Elif ABC <0
Int B =-1;
Printf ("% d \ n", B );
# Else
Int c = 0;
Printf ("% d \ n", c );
# Endif
}
From 360 Knowledge Network