17.05.2015 Views

TMS34010 C Compiler - Al Kossow's Bitsavers

TMS34010 C Compiler - Al Kossow's Bitsavers

TMS34010 C Compiler - Al Kossow's Bitsavers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

#define/#undef<br />

Define/Undefine Constant Directives<br />

Syntax<br />

Description<br />

#define name[(arg, ... ,arg)] token-string<br />

#undef name<br />

The preprocessor supports two directives for defining and undefining constants:<br />

• The #define directive assigns a string to a constant. Subsequent<br />

occurrences of name are replaced by token-string. The name can be<br />

immediately followed by an argument list; the arguments are separated<br />

by commas, and the list is enclosed in parentheses. Each occurrence<br />

of an argument is replaced by the corresponding set of<br />

tokens from the comma-separated string.<br />

When a macro with arguments is expanded, the arguments are placed<br />

into the expanded token-string unchanged. After the entire tokenstring<br />

is expanded, the preprocessor scans again for names to expand<br />

at the beginning of the newly created token-string, which allows for<br />

nested macros.<br />

Note that there is no space between name and the open parenthesis<br />

at the beginning of the argument list. A trailing semicolon is not required;<br />

if used, it is treated as part of the token-string.<br />

• The #undef directive undefines the constant name; that is, it causes<br />

the preprocessor to forget the definition of name.<br />

Example<br />

The following example defines the constant f:<br />

#define f(a,b,c) 3*a+b-c<br />

The following line of code uses the definition of f:<br />

f(27,begin,minus)<br />

This line is expanded to:<br />

3*27+begin-minus<br />

To undefine f, enter:<br />

#undef<br />

f<br />

B-2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!