You are on page 1of 1

C Compiler Reference Manual

#IFDEF
#IFNDEF
#ELSE
#ELIF
#ENDIF
Syntax:

#ifdef id
code
#elif
code
#else
code
#endif
#ifndef id
code
#elif
code
#else
code
#endif

Elements:

id is a preprocessor identifier, code is valid C source code.

Purpose:

This directive acts much like the #IF except that the
preprocessor simply checks to see if the specified ID is
known to the preprocessor (created with a #DEFINE).
#IFDEF checks to see if defined and #IFNDEF checks to see
if it is not defined.

Examples:

#define debug

// Comment line out for no debug

...
#ifdef DEBUG
printf("debug point a");
#endif

Example Files:

ex_sqw.c

Also See:

#if

46

You might also like