DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Complying with standard C

Third example: integral constants

In the following code, assume ints are 16 bits.

   int f(void)
   {
       int i = 0;

return i > 0xffff; }

Because the hexadecimal constant's type is either int (with a value of -1 on a two's-complement machine) or an unsigned int (with a value of 65535), the comparison will be true on a non-ANSI C compiler (-Xt mode), and false on an ANSI C compiler (-Xa and -Xc modes).

An appropriate cast clarifies the code:

(The U suffix character is a new feature of ANSI C and will probably produce an error message with older compilers.)
Next topic: Tokenization and preprocessing
Previous topic: Integral constants

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005