Section 2: Compiler
99
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
The following example illustrates the rules for concatenating tokens:
#define paste(a,b)
a ## b
#define opnd_info(n)
op##n##_info(size##n(),type##n())
#define HITHERE
hello, world!
paste(HI,THERE)
opnd_info(2)
/* Results After Preprocessing */
hello, world!
op2_info(size2(),type2())
The following example illustrates the rules for creating string literals:
#define stringize(s)
# s
#define expand(s)
stringize(s)
#define max(a,b)
((a) > (b) ? (a) : (b))
#define show_macro(m)
printf(#m " becomes " expand(m)"\n")
show_macro(max(a,b))
/* Results After Preprocessing */
printf("max(a,b)" " becomes " "((a) > (b) ? (a) : (b))""\n")
After string concatenation, the above result appears as follows:
printf("max(a,b) becomes ((a) > (b) ? (a) : (b))\n")
Space around the ' # ' and ' ## ' operators is optional.
2.16.6.
Line and Name Control
A preprocessing directive of the following form causes the compiler to behave as
if the line number of the next source line is the number specified by the decimal
constant in the directive:
#line decimal_constant
A preprocessing directive of the following form sets the line number as specified
above and changes the presumed name of the source file to be the filename
shown in the string literal:
#line decimal_constant "file_name"
Macro names among the preprocessor tokens following the #line directive are
processed the same as any other macro names in the file. The directive that
results after macro substitution must match one of the two previous forms and is
processed accordingly.