
•
Description
The #define directive defines string constants that are substituted into
a source line before the source line is evaluated. The main purpose is to
improve source code readability and maintainability. If the replaced-text
requires more than one line, the backslash (\) is used to indicate multiple
lines.
•
Example
#define TOTAL_COUNT
40
#define USERNAME
"Henry"
#define MAX(a,b)
((a>b)?a:b)
→
#error
•
Syntax
#error
"
message-string"
•
Description
The #error directive generates a user-defined diagnostic message, mes-
sage-string.
•
Example
#if
TOTAL_COUNT > 100
#error
"Too many count."
#endif
→
Conditional inclusion: #if #else #endif
•
Syntax
#if
expression
source codes
[
#else
source codes]
#endif
•
Description
The #if and #endif directives pairs are used for conditionally compiling
code depending upon the evaluation of the expression. The #else which
is optional provides an alternative compilation method. If the expression
is nonzero, then the source code below the #if statement will be compiled.
Otherwise, the source code that follows the #else statement, if it exists,
will be compiled.
•
Example
#define MODE 2
#if MODE > 0
#define DISP_MODE MODE
#else
#define DISP_MODE 7
#endif
Chapter 9 Holtek C Language
103
Содержание HT-IDE
Страница 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Страница 12: ...HT IDE User s Guide 2 ...
Страница 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Страница 24: ...HT IDE User s Guide 14 ...
Страница 70: ...HT IDE User s Guide 60 ...
Страница 76: ...HT IDE User s Guide 66 ...
Страница 92: ...HT IDE User s Guide 82 ...
Страница 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Страница 94: ...HT IDE User s Guide 84 ...
Страница 148: ...HT IDE User s Guide 138 ...
Страница 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Страница 154: ...HT IDE User s Guide 144 ...
Страница 192: ...HT IDE User s Guide 182 ...
Страница 194: ...HT IDE User s Guide 184 ...
Страница 218: ...HT IDE User s Guide 208 ...
Страница 235: ...P a r t V Appendix Part V Appendix 225 ...
Страница 236: ...HT IDE User s Guide 226 ...
Страница 250: ...HT IDE User s Guide 240 ...