- UNIT-I (Array)
strlen(),strcpy(), strcat() ,strcmp()
Definition
Macro substitution directives
File inclusion directives
Conditional compilation
Bitwise Operators
Shift operators
Masks
Bitfield
Macro substitution directives
File inclusion directives
Conditional compilation
Bitwise Operators
Shift operators
Masks
Bitfield
Conditional compilation
Conditional Compilation orders help to assemble a particular bit of the program or let us skip assemblage of some particular piece of the program dependent on certain conditions. In our past article, we have examined two such orders 'ifdef' and 'endif'. Right now will talk about #ifndef, #if, #else and #elif
Six directives are available to control conditional compilation
#if
#ifdef
#ifndef
#else
#elif
The
#if
a directive
syntax:
#if constant-expression newline
This directive checks whether the constant-expression is true (nonzero). The operand must be a constant integer expression that does not contain any increment (++), decrement (- -),
sizeof
, pointer (*), address (&), and cast operators.The #ifdef Directive
syntax:
#ifdef identifier newline
This directive checks whether the identifier is currently defined. Identifiers can be defined by a
#define
directive or on the command line. If such identifiers have not been subsequently undefined, they are considered currently defined.The #ifndef Directive
syntax:
#ifndef identifier newline
This directive checks to see if the identifier is not currently defined.
The #else Directive
syntax:
#else newline
This directive delimits alternative source text to be compiled if the condition tested for in the corresponding
#if
, #ifdef
, or #ifndef
a directive is false. An #else
a directive is optional.The #elif Directive
syntax:
#elif constant-expression newline
The
#elif
directive performs a task similar to the combined use of the else-if
statements in C. This directive delimits alternative source lines to be compiled if the constant expression in the corresponding #if
, #ifdef
, #ifndef
, or another #elif
a directive is false and if the additional constant expression presented in the #elif
the line is true. An #elif
a directive is an optionThe #endif Directive
syntax:
#endif newline
This directive ends the scope of the
#if
, #ifdef
, #ifndef
, #else
, or #elif
directive.
The number of necessary
#endif
directives changes according to whether the elif
or #else
a directive is used. Consider the following equivalent examples:#if true #if true . . . . . . #elif true . . #else . #if false . . #endif . . #endif #endif
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें