On 01/12/2010 01:25 PM, Colin McCabe wrote:
util.c: In function ‘objid_init’:
util.c:331: warning: integer constant is too large for ‘long’ type

with

[cmcc...@stargazer tabled]$ gcc --version
gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)

Now that I wrote a little test program, I can see that gcc handles the
constant correctly. It still issues a warning for some reason.
I guess gcc's C99 support is not perfect.

Is this on a 32-bit on 64-bit compiler platform?

Because Linux does

        #if __WORDSIZE == 64
        typedef unsigned long int       uint64_t;
        #else
        __extension__
        typedef unsigned long long int  uint64_t;
        #endif

which causes the comparison type (uint64_t objcount) to vary between 32-bit and 64-bit platforms, even if the number of bits used to store it remains the same.

Strange...

        Jeff


#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>

#if 1
#define X 0xff00000000000000
#else
#define X x
#endif

int main (int argc, char *argv[])
{
        uint32_t x = 0;

        if (__builtin_types_compatible_p (typeof (X), int))
                printf("type: int\n");
        else if (__builtin_types_compatible_p (typeof (X), unsigned int))
                printf("type: unsigned int\n");
        else if (__builtin_types_compatible_p (typeof (X), long))
                printf("type: long\n");
        else if (__builtin_types_compatible_p (typeof (X), unsigned long))
                printf("type: unsigned long\n");
        else if (__builtin_types_compatible_p (typeof (X), long long))
                printf("type: long long\n");
        else if (__builtin_types_compatible_p (typeof (X), unsigned long long))
                printf("type: unsigned long long\n");
        else
                printf("type: unknown\n");
        
        (void) x;

        return 0;
}

Reply via email to