Le sam 19/07/2003 à 13:01, Shachar Shemesh a écrit :
Todd Vierling wrote:
On Sat, 19 Jul 2003, Vincent Béron wrote:
: That's an easy one. One an Alpha, sizeof(int) != sizeof(foo *). I think : sizeof(int) == 8, while sizeof(foo *) == 4.
Other way round. sizeof(int) == 4; sizeof(void *) == 8.
: gcc is kind enough to warn you about this potentially nasty situation, : although in these particular cases I don't see how putting the pointer : in something larger will create a problem.
Use intptr_t. If that's not available (via autoconf test), typedef intptr_t to be "unsigned long" locally, as "long" is the size of a pointer on all typical ILP32 and LP64 hosts.
The reason something is a warning and not an error is that it MAY have a legitimate use. As such, there should always be a way to change the code so that it will keep the same meaning, but will avoid the warning in the future. In this particular case, for example, what does applying the following change do?
- if (!((int)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04x>",
(int)id & 0xffff );
- if (!((int)id >> 16)) return wine_dbg_sprintf( "<guid-0x%04x>",
(UINT16)id );
You'll have to do it also at the beginning of the line.
I'm a bit confused. gcc seems to be warning us about an explicit cast? I always thought that, in C, explicit casts are THE way of avoiding compile time warnings. Why should one change the semantic meaning of the code just so that gcc is pacified?
I think for pointers (especially when you change the size of the result) gcc is more picky. Compile the attached program to verify.
And I don't remember Steven saying that he actually used gcc or even Linux on the Alpha, it could be the DEC cc under Tru-64...
Vincent