qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] fix gcc4 compile warnings


From: Paul Brook
Subject: Re: [Qemu-devel] [PATCH] fix gcc4 compile warnings
Date: Fri, 30 Nov 2007 14:48:38 +0000
User-agent: KMail/1.9.7

> > What solution do you prefer for the opaque types? I have used the simple:
> >  >> -    void *args[MAX_ARGS];
> >  >> +    intptr_t args[MAX_ARGS];
> >
> > A more portable and clean solution would be this:
> > -    void *args[MAX_ARGS];
> > +    union
> > +    {
> > +        void* ptr;
> > +        int i;
> > +    } args[MAX_ARGS];
> > If you prefer this, I can change the patch accordingly.
>
> I'm not sure why you get a warning here and I'm unable to run a build
> at the moment. A void * should be able to store some (unknown size)
> integer regardless of the platform.

Unfortunately there is no portable and reliable solution, other than avoiding 
storing arbitrary integers in pointer variables.

The details have been discussed on this list previously. The short version is 
that C89 guaranteed that "long" was at least as big as "void *". C99 removed 
this guarantee, and introduced intptr_t instead. To further complicate 
matters the only target (win64) that breaks the C89 guarantee doesn't support 
C99.

Paul




reply via email to

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