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

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004