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.

PreProcessor<br />

Note: you may NOT use C variables in the #IF. Only preprocessor identifiers<br />

created via #define can be used.<br />

The preprocessor expression DEFINED(id) may be used to return 1 if the id is<br />

defined and 0 if it is not.<br />

== and != operators now accept a constant string as both operands. This allows<br />

for compile time comparisons and can be used with GETENV() when it returns<br />

a string result.<br />

Examples:<br />

#if MAX_VALUE > 255<br />

long value;<br />

#else<br />

int value;<br />

#endif<br />

#if getenv(“DEVICE”)==”PIC16F877”<br />

//do something special for the PIC16F877<br />

#endif<br />

Example Files:<br />

Also See:<br />

ex_extee.c<br />

#IFDEF, #IFNDEF, getenv()<br />

#error<br />

Syntax:<br />

Elements:<br />

Purpose:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

#ERROR text<br />

#ERROR / warning text<br />

#ERROR / information text<br />

text is optional and may be any text<br />

Forces the compiler to generate an error at the location this<br />

directive appears in the file. The text may include macros that<br />

will be expanded for the display. This may be used to see the<br />

macro expansion. The command may also be used to alert the<br />

user to an invalid compile time situation.<br />

#if BUFFER_SIZE>16<br />

#error Buffer size is too large<br />

#endif<br />

#error Macro test: min(x,y)<br />

ex_psp.c<br />

#WARNING<br />

103

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

Saved successfully!

Ooh no, something went wrong!