🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3181

Re: gcc and NULL function pointers.

#3181
From: Peter da Silva
Date: Mon, 24 Jun 1991 18:16
41 lines
2361 bytes
In article <16481@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes:
> In article <C62C9-2@xds13.ferranti.com> peter@ficc.ferranti.com (Peter da Silva) writes:
> >> What about systems where different pointer types have different sizes?
> >Then a different definition of NULL is appropriate.

> NO NO NO.  There is NO appropriate definition of NULL if your criterion
> be that it "work" without proper casting.

No, my criterion is that it allow the maximum possible amount of comp.sources
to compile and execute. If there is no definition that'll catch 100%, then
we'll have to be satisfied with 75%, or 50%. If an unadorned "0" is the best
solution, that's the one to use. If "((void *)0)" is the best solution, then
that's the one to use.

One or the other is appropriate for any given machine. Whichever one it is
depends entirely on the machine.

> If you declare it as, say,
> something that will work as an int*, then it cannot work as a char* on
> a system where different pointer types have different sizes.

That's right, and on that system you use "0". If ints and pointers *also*
have different sizes, you're screwed. Too bad.

> In other words, the problem you think you're trying to solve cannot be
> solved in general.

No, the problem *you* think I'm trying to solve can't be solved. That's OK.
Since I'm not trying to solve that particular problem it doesn't bother me.

> All this stuff was thoroughly discussed in X3J11, by the way.  The
> outcome was what you now see specified in the C standard.

Uh, huh. And that is that "0" and "((void *)0)" are acceptable.

Pick one.

Depending on the hardware and compiler.
-- 
Peter da Silva; Ferranti International Controls Corporation; +1 713 274 5180;
Sugar Land, TX  77487-5012;         `-_-' "Have you hugged your wolf, today?"
Technical Details
Message-ID: <XZ4C6T6@xds13.ferranti.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!ficc!peter
References: <MR0CV2H@xds13.ferranti.com> <16468@smoke.brl.mil> <C62C9-2@xds13.ferranti.com> <16481@smoke.brl.mil>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!ficc!peter
From: peter@ficc.ferranti.com (Peter da Silva)
Newsgroups: comp.std.c
Subject: Re: gcc and NULL function pointers.
Message-ID: <XZ4C6T6@xds13.ferranti.com>
Date: 24 Jun 91 18:16:57 GMT
References: <MR0CV2H@xds13.ferranti.com> <16468@smoke.brl.mil> <C62C9-2@xds13.ferranti.com> <16481@smoke.brl.mil>
Reply-To: peter@ficc.ferranti.com (Peter da Silva)
Organization: Xenix Support, FICC
Lines: 41