0% found this document useful (0 votes)
20 views

C Reference Manual - October 2005.56

This document provides information about preprocessor directives in C code including #if, #elif, #else and #endif. It explains that #if evaluates a constant expression and will process the code until #else or #endif if the expression is non-zero. Only preprocessor identifiers from #define can be used in expressions, not C variables. Examples demonstrate conditionally compiling code based on expression results.

Uploaded by

diegoifg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

C Reference Manual - October 2005.56

This document provides information about preprocessor directives in C code including #if, #elif, #else and #endif. It explains that #if evaluates a constant expression and will process the code until #else or #endif if the expression is non-zero. Only preprocessor identifiers from #define can be used in expressions, not C variables. Examples demonstrate conditionally compiling code based on expression results.

Uploaded by

diegoifg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

C Compiler Reference Manual

Examples:

#id
#id
#id

0x1234
"serial.num"
CHECKSUM

Example Files:

ex_cust.c

Also See:

None

#IF expr
#ELSE
#ELIF
#ENDIF
Syntax:

#if expr
code
#elif expr //Optional, any number may be used
code
#else
//Optional
code
#endif

Elements:

expr is an expression with constants, standard operators


and/or preprocessor identifiers. Code is any standard c
source code.

Purpose:

The pre-processor evaluates the constant expression and if it


is non-zero will process the lines up to the optional #ELSE or
the #ENDIF.
Note: you may NOT use C variables in the #IF. Only
preprocessor identifiers created via #define can be used.
The preprocessor expression DEFINED(id) may be used to
return 1 if the id is defined and 0 if it is not.

Examples:

#if MAX_VALUE > 255


long value;
#else
int value;
#endif

44

You might also like