(char *)(-1)

david Fridley david at psitech.UUCP
Sat Jul 29 05:53:41 AEST 1989


In article <1063 at tukki.jyu.fi>, tarvaine at tukki.jyu.fi (Tapani Tarvainen) writes:
> In article <118 at psitech.UUCP> david at psitech.UUCP (david Fridley) writes:
> 
> If -1 isn't safe, is there any other value (besides NULL) that can
> safely be returned from a (any *) function to indicate error?
> -- 
> Tapani Tarvainen    (tarvaine at jyu.fi, tarvainen at finjyu.bitnet)

On some systems, even NULL can accidently be a valid pointer.  The environment
has to take precautions to prevent this, like starting virtual data sections at
100 instead of 0, etc.  But since NULL is written in K&R and (-1) is not, it
is not garanteed to be portable.  I have not had any problems though, and it
sure is convenient to be able to return more than one fail code from a function
that returns a pointer.  Does any body have an environment where they think
this will not work? 


-- 
david.
DISCLAIMER: If it's important have a backup.  If it ain't broke don't fix it.
Proceed at your own risk.  My oponions are MY own.  Spelling does not count.
My fondest dream is to leave this planet.



More information about the Comp.std.c mailing list