| Syntax: | Default: |
| lang(preserveUnsignedPromotion[,
yes]) lang(preserveUnsignedPromotion, no) |
lang(preserveUnsignedPromotion, no) |
This option controls whether unsignedness is preserved when an integer value is promoted in C code. This option does not apply when explicit type casts are used, and affects only integral promotions. It controls the signedness of the type of the resulting value, not its sign.
By default, integer promotions conform to the C standard. Such type conversions preserve values but not signedness.
If you set preserveUnsignedPromotion to yes, type conversions preserve signedness. That is, unsigned types will remain unsigned when they are promoted. This does not conform to the C standard.
If an expression mixes integer types, VisualAge C++ applies any implicit conversions required to make the types the same. This option controls whether the conversions applied are "unsigned preserving" or "value preserving". In unsigned preserving conversions, an unsigned short int or an unsigned char would be promoted to an unsigned int. In value preserving conversions, they would be promoted to a signed int, except in implementations where the size of a short is the same size as an int.
For example, the sum of a signed int plus an unsigned char would be treated in the following ways, as determined by the setting of this option:
| Setting | Effect |
|---|---|
| lang(preserveUnsignedPromotion, no) | Convert the unsigned char to a positive, signed int, then add two signed ints, giving a signed int. This is the default. |
| lang(preserveUnsignedPromotion, yes) | Convert the unsigned char to an unsigned int, convert the signed int to an unsigned int, then add the two unsigned ints, giving a result of type unsigned int. |
The bit pattern remains the same in either case, but its type and meaning will be different, which could affect subsequent operations.
![]()
C Compilation
Configuration Files
![]()
Language Options for C
Build Options
