Sun WorkShop Compiler C 5.0 User's Guide

Integral Constants

As with expressions, the rules for the types of certain integral constants have changed. In K&R C, an unsuffixed decimal constant had type int only if its value fit in an int; an unsuffixed octal or hexadecimal constant had type int only if its value fit in an unsigned int. Otherwise, an integral constant had type long. At times, the value did not fit in the resulting type. In ANSI/ISO C, the constant type is the first type encountered in the following list that corresponds to the value:

unsuffixed decimal:

int, long, unsigned long

unsuffixed octal or hexadecimal:

int, unsigned int, long, unsigned long

U suffixed:

unsigned int, unsigned long

L suffixed:

long, unsigned long

UL suffixed:

unsigned long

The ANSI/ISO C compiler warns you, when you use the -xtransition option, about any expression whose behavior might change according to the typing rules of the constants involved. The old integral constant typing rules are used only in the transition mode; the ANSI/ISO and conforming modes use the new rules.