11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Error and Warning MessagesA quick check with your calculator reveils that 240 * 137 is 32880 which can easily be stored inan unsigned int, but a warning is produced. Why? Because 240 and 137 and both signed intvalues. Therefore the result of the multiplication must also be a signed int value, but a signedint cannot hold the value 32880. (Both operands are constant values so the code generator canevaluate this expression at compile time, but it must do so following all the ANSI rules.) Thefollowing code forces the multiplication to be performed with an unsigned result:i = 240u * 137; /* force at least one operand to be unsigned */(752) conversion to shorter data type (Code Generator)Truncation may occur in this expression as the lvalue is of shorter type than the rvalue, e.g.:char a;int b, c;a = b + c; /* conversion of int to char may result in truncation */(753) undefined shift (* bits) (Code Generator)An attempt has been made to shift a value by a number of bits equal to or greater than the number ofbits in the data type. This will produce an undefined result on many processors. This is non-portablecode and is flagged as having undefined results by the C Standard, e.g.:int input;input <

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

Saved successfully!

Ooh no, something went wrong!