SW500010 Microchip Technology, SW500010 Datasheet - Page 429

HI-TECH C PRO FOR PIC10/12/16

SW500010

Manufacturer Part Number
SW500010
Description
HI-TECH C PRO FOR PIC10/12/16
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC10/12/16r
Datasheets

Specifications of SW500010

Supported Families
PIC10, PIC12, PIC16
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC10/12/16
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC10, PIC12, PIC14, PIC16, PIC16E
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
019P
778-1006
778-1006
Error and Warning Messages
(751) arithmetic overflow in constant expression
A constant expression has been evaluated by the code generator that has resulted in a value that is
too big for the type of the expression. The most common code to trigger this warning is assignments
to signed data types. For example:
As a signed 8-bit quantity, c can only be assigned values -128 to 127. The constant is equal to
255 and is outside this range. If you mean to set all bits in this variable, then use either of:
which will set all the bits in the variable regardless of the size of the variable and without warning.
A quick check with your calculator reveals that 240 * 137 is 32880 which can easily be stored in
an unsigned int, but a warning is produced. Why? Because 240 and 137 and both signed
int values. Therefore the result of the multiplication must also be a signed int value, but
a signed int cannot hold the value 32880. (Both operands are constant values so the code
generator can evaluate this expression at compile time, but it must do so following all the ANSI
rules.) The following code forces the multiplication to be performed with an unsigned result:
(752) conversion to shorter data type
Truncation may occur in this expression as the lvalue is of shorter type than the rvalue, e.g.:
This warning can also be triggered by intermediate values overflowing. For example:
signed char c;
c = 0xFF;
c = ~0x0;
c = -1;
unsigned int i;
i = 240 * 137;
i = 240u * 137;
char a;
int b, c;
a = b + c;
/ * int to char conversion
may result in truncation * /
/ * assume ints are 16 bits wide * /
/ * this should be okay, right? * /
/ * force at least one operand
to be unsigned * /
(Code Generator)
(Code Generator)
429

Related parts for SW500010