The #define Statement
One of the primary uses of the #define
statement is to assign symbolic names to program constants. The preprocessor statement
#define TRUE 1
defines the name TRUE
and makes it equivalent to the value 1
. The name TRUE
can subsequently be used anywhere in the program where the constant 1
could be used. Whenever this name appears, the preprocessor automatically substitutes its defined value of 1
into the program. For example, you might have the following Objective-C statement that uses the defined name TRUE
:
gameOver = TRUE;
This statement assigns the value of TRUE
to gameOver
. You don’t need to concern yourself with the actual value you defined for TRUE
, but because you do know that you defined it to be 1
, the preceding ...
Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.