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.

COMPILER WARNING MESSAGES<br />

<strong>Compiler</strong> Warning Messages<br />

#error/warning<br />

Assignment inside relational expression<br />

Although legal it is a common error to do something like if(a=b) when it was intended to do<br />

if(a==b).<br />

Assignment to enum is not of the correct type.<br />

This warning indicates there may be such a typo in this line:<br />

Assignment to enum is not of the correct type<br />

If a variable is declared as a ENUM it is best to assign to the variables only elements of the<br />

enum. For example:<br />

enum colors {RED,GREEN,BLUE} color;<br />

...<br />

color = GREEN; // OK<br />

color = 1; // Warning 209<br />

color = (colors)1; //OK<br />

Code has no effect<br />

The compiler can not discern any effect this source code could have on the generated code.<br />

Some examples:<br />

1;<br />

a==b;<br />

1,2,3;<br />

Condition always FALSE<br />

This error when it has been determined at compile time that a relational expression will never be<br />

true. For example:<br />

int x;<br />

if( x>>9 )<br />

Condition always TRUE<br />

This error when it has been determined at compile time that a relational expression will never be<br />

false. For example:<br />

#define PIN_A1 41<br />

...<br />

if( PIN_A1 ) // Intended was: if( input(PIN_A1) )<br />

Function not void and does not return a value<br />

Functions that are declared as returning a value should have a return statement with a value to<br />

be returned. Be aware that in C only functions declared VOID are not intended to return a value.<br />

If nothing is specified as a function return value "int" is assumed.<br />

Duplicate #define<br />

The identifier in the #define has already been used in a previous #define. To redefine an<br />

identifier use #UNDEF first. To prevent defines that may be included from multiple source do<br />

something like:<br />

#ifndef ID<br />

#define ID text<br />

#endif<br />

Feature not supported<br />

349

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

Saved successfully!

Ooh no, something went wrong!