Date: Sat, 15 Feb 1997 11:26:39 +0100 From: "Arne H. Juul" <Arne.Juul@idt.ntnu.no> To: eivind@dimaga.com Cc: hackers@freebsd.org Subject: Re: NULL as ((void*)0) (was Re: strlen() question) Message-ID: <199702151026.LAA23547@pat.idt.unit.no> In-Reply-To: Your message of "Sat, 15 Feb 1997 01:48:58 %2B0100" References: <3.0.32.19970215014856.00c14100@dimaga.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> BTW: I just got another idea - if we can turn the definition of NULL > between ((void*)0) and 0 we can detect if NULL is abused if compiling on a > machine with different sizeof(void*) and sizeof(int). If used correctly, > code will be equal no matter what the definition - if used incorrectly, > different code should result. This can provide fairly automatic detection > of errors, provided we have two different builds. I think this is a good idea too, but it isn't really neccessary to change anything in the main source tree for this (though it would make it easier if there was just one place to change, of course). I have done a make world with (most) of the #define's for NULL set to ((void *)0) and have found a few minor bugs already (23% done). PR will follow. BTW, as far as I can see from my C standard the rules for NULL are pretty lax; both (1-1) and something like typedef enum { __ournull=0 } __dummynull; #define NULL __ournull should be legal. - Arne H. J.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702151026.LAA23547>