From: Paul Brook <paul@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] fix gcc4 compile warnings
Date: Fri, 30 Nov 2007 14:48:38 +0000 [thread overview]
Message-ID: <200711301448.39882.paul@codesourcery.com> (raw)
In-Reply-To: <fb249edb0711300630j74911cf6lba75c397b9f7c8fe@mail.gmail.com>
> > 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
next prev parent reply other threads:[~2007-11-30 14:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 23:58 [Qemu-devel] [PATCH] fix gcc4 compile warnings André Przywara
2007-11-30 13:23 ` andrzej zaborowski
2007-11-30 14:10 ` Andre Przywara
2007-11-30 14:24 ` Samuel Thibault
2007-11-30 14:30 ` andrzej zaborowski
2007-11-30 14:38 ` Samuel Thibault
2007-11-30 14:48 ` Paul Brook [this message]
2007-11-30 14:56 ` Andre Przywara
2007-11-30 14:06 ` Paul Brook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711301448.39882.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).