C– – Compiler

5.5.4C– – Directives

C– – has a limited number of directives and some additional directives not found in ANSI C compilers. The following directives are recognized by the compiler.

5.5.4.1#define

This directive is used to introduce 2 types of macros, in typical C fashion:

Without Arguments:

defines a replacement string for a given string

Example:

#define PI 3.1415926535

Every occurrence of the token PI will henceforth be replaced with the string 3.1415926535.

If there is no replacement string, the given string is deemed defined: this can be used in conjunction with the #ifdef / #ifndef directives. It is also possible to undefine a macro with the #undefine directive.

With Arguments:

The macro name must be immediately followed by a pair of parenthesis, which introduces the arguments. This is completely compatible with the usual C definition.

Example:

#define modulo(i,j) (i%j)

Every occurrence of the word modulo followed by an expression in parentheses will be replaced by (i%j), where i is the first argument in the parenthesis, and j the second argument. modulo((a*b),c) will thus be replaced by ((a*b)%c).

5.5.4.2#undefine

The string following this directive is removed from the list of macros. There is no warning if the string is not found in the macro list.

5.5.4.3#include

As in regular C, this directive allows for the insertion of a file into the current file. If the file name that follows is enclosed in < >, the system searches the include directories for the file, otherwise, if it is enclosed in “”, the current directory is searched.

5-18

Page 314
Image 314
Texas Instruments MSP50C6xx Directives, Without Arguments, Defines a replacement string for a given string, With Arguments