qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] block: Explicitly specify 'unsigned long long'


From: Laszlo Ersek
Subject: Re: [Qemu-devel] [PATCH] block: Explicitly specify 'unsigned long long' for VHDX 64-bit constants
Date: Fri, 14 Mar 2014 19:57:30 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 03/14/14 19:49, Laszlo Ersek wrote:

> One good example is for 6.4.4.1 "Integer constants":
> 
>                       QUIET CHANGE IN C99
> 
>     Unsuffixed integer constants may have different types in C99 than
>     in C89. Such constants greater than LONG_MAX are of type unsigned
>     long in C89, but are of type long long in C99 (if long long has
>     more range than long).
> 
> I have no clue what gnu89 does.

x.c:

  #include <stdio.h>

  int
  main(void)
  {
    fprintf(stdout, "%u\n", (unsigned)sizeof 2147483648);
    return 0;
  }

The following script:

  for I in c89 gnu89 c99 gnu99; do
    echo "==== $I ===="
    gcc -m32 -o x -std=$I x.c
    ./x
  done

outputs:

==== c89 ====
x.c: In function 'main':
x.c:6:3: warning: this decimal constant is unsigned only in ISO C90
[enabled by default]
   fprintf(stdout, "%u\n", (unsigned)sizeof 2147483648);
   ^
4
==== gnu89 ====
x.c: In function 'main':
x.c:6:3: warning: this decimal constant is unsigned only in ISO C90
[enabled by default]
   fprintf(stdout, "%u\n", (unsigned)sizeof 2147483648);
   ^
4
==== c99 ====
8
==== gnu99 ====
8

Laszlo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]