17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Elements:<br />

Purpose:<br />

None<br />

This pre-processor identifier is replaced at compile time with the date of the<br />

compile in the form: "31-JAN-03"<br />

Examples:<br />

printf("Software was compiled on ");<br />

printf(__DATE__);<br />

Example<br />

Files:<br />

Also See:<br />

None<br />

None<br />

#define<br />

Syntax:<br />

Elements:<br />

Purpose:<br />

#define id text<br />

or<br />

#define id(x,y...) text<br />

id is a preprocessor identifier, text is any text, x,y is a list of local preprocessor<br />

identifiers, and in this form there may be one or more identifiers separated by commas.<br />

Used to provide a simple string replacement of the ID with the given text from this point<br />

of the program and on.<br />

In the second form (a C macro) the local identifiers are matched up with similar<br />

identifiers in the text and they are replaced with text passed to the macro where it is<br />

used.<br />

If the text contains a string of the form #idx then the result upon evaluation will be the<br />

parameter id concatenated with the string x.<br />

If the text contains a string of the form #idx#idy then parameter idx is concatenated with<br />

parameter idy forming a new identifier.<br />

Within the define text two special operators are supported:<br />

#x is the stringize operator resulting in "x"<br />

x##y is the concatination operator resulting in xy<br />

The varadic macro syntax is supported where the last parameter is specified as ... and<br />

the local identifier used is __va_args__. In this case, all remaining arguments are<br />

combined with the commas.<br />

Examples:<br />

#define BITS 8<br />

a=a+BITS; //same as a=a+8;<br />

#define hi(x) (x

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

Saved successfully!

Ooh no, something went wrong!