
SimplIQ Software Manual Program Development and Execution
MAN-SIMSW (Ver. 1.4)
6-16
Example 1:
#define DEBUG_FLAG
Defines the identifier DEBUG_FLAG.
Example 2:
#define ARR_LEN 10
Defines the identifier ARR_LEN as the integer constant 10. Each occurrence of ARR_LEN
will be replaced by 10.
Example 3:
#define ARR_LEN num+10
Defines the identifier ARR_LEN as the string
num+10
. The precompiler cannot evaluate
token_string because
num
is not a constant expression. Each occurrence of ARR_LEN will be
replaced by this string.
Example 4:
#define DEBUG_FLAG
. . .
#define DEBUG_FLAG
The first statement defines the identifier
DEBUG_FLAG
and the second statement is illegal
because it redefines the #define with an already-defined identifier.
Example 5:
#define DEBUG_FLAG
. . .
#undef DEBUG_FLAG
. . .
#define DEBUG_FLAG 1
The first statement defines the identifier
DEBUG_FLAG
and the second statement removes this
identifier. The third statement defines
DEBUG_FLAG
again, and is legal because the previous
definition of
DEBUG_FLAG
was removed by the #undef directive. This identifier has a
token_string and each occurrence of
DEBUG_FLAG
will be replaced by 1.
Example 6:
#define MAX_LEN 10
#define ARR_LEN MAX_LEN +10
. . .
#undef MAX_LEN
. . .
int arr[ARR_LEN];
This example contains two identifiers with token_strings that have been successfully
evaluated. The identifier
ARR_LEN
contains
MAX_LEN
as part of its constant expression. In the
last statement, the identifier
ARR_LEN
will be replaced with 20 despite the fact that the
identifier
MAX_LEN
was removed with the #undef directive.
Comentarios a estos manuales