Developer Documentation
PATH  Mac OS X Documentation > Developer Tools > The GNU C Preprocessor


Previous | Contents | Next

Conditionals

In a macro processor, a conditional is a command that allows part of the program to be ignored during compilation, on some conditions. In the C preprocessor, a conditional can test either an arithmetic expression or whether a name is defined as a macro.

A conditional in the C preprocessor resembles an if statement in C, but it's important to understand the difference between them. The condition in an if statement is tested during the execution of your program. Its purpose is to allow your program to behave differently from run to run, depending on the data it's operating on. The condition in a preprocessor conditional command is tested when your program is compiled. Its purpose is to allow different code to be included in the program depending on the situation at the time of compilation.

There are three reasons to use a conditional:

Most programs using only Mac OS X API won't need to use preprocessor conditionals.

Syntax of Conditionals

Keeping Deleted Code for Future Reference

Conditionals and Macros


The GNU C Preprocessor

Previous | Contents | Next