qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] error compiling hw/sh7750.c


From: Andreas Schwab
Subject: Re: [Qemu-devel] error compiling hw/sh7750.c
Date: Sun, 11 Nov 2007 18:49:47 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

Carlo Marcelo Arenas Belon <address@hidden> writes:

> and run a test, the problem is in /usr/include/iso/stdio_iso.h that defined
> NULL as an int and not a pointer as shown by :

NULL is not a pointer, it is a null pointer constant, and 0 is a valid
null pointer constant.

> contradicting (at least in spirit) the C99 (ISO/IEC 9899:TCS) standard that
> says :
>
>   "A pointer to void shall have the same representation and alignment 
>    requirements as a pointer to a character type"

A null pointer constant is not a pointer.  It can be convert to a
pointer, but that happens only in the right context (through explicit or
implicit conversions).

> and therefore makes sizeof(*NULL) == 1 solving the problem to compile as it is
> done if applying the following patch :
>
> Carlo
>
> ---
> --- qemu/hw/sh7750.c  Sun Oct  7 09:31:11 2007
> +++ qemu/hw/sh7750.c  Sun Nov 11 16:13:13 2007
> @@ -29,6 +29,9 @@
>  #include "sh7750_regnames.h"
>  #include "sh_intc.h"
>  
> +#undef NULL
> +#define NULL ((void *)0)

This does not make it better, since sizeof(void) is still not allowed in
C.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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