Date: Sat, 30 Jan 1999 00:49:58 +1100 From: Bruce Evans <bde@zeta.org.au> To: brian@Awfulhak.org, dillon@FreeBSD.ORG Cc: cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Subject: Re: cvs commit: src/sys/sys kernel.h Message-ID: <199901291349.AAA06463@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>A similar thing is the more fundamental problem with const - there's no >way of declaring a function that accepts ``const something *'' and >returns ``whatever was passed *''. You mean ``whatever the type was before it was passed''. >Does anyone know if gcc has an ``extension'' to deal with this ? For It has the non-useful extension g++ :-). >example, the strchr() prototype is wrong because I can > > const char *donttouch; > char dowhatyouwant; ^* > > .... > dowhatyouwant = strchr(donttouch, *donttouch); You can do that anyway by casting away the const. Don't do that. >The prototype is doubly wrong because there's no correct way to write >the function - not without casting the const char * to a char *. There is no problem with implementing strchr(), only a minor problem with its use. Casting the const char * to char * is a correct way of implementing it. A similar problem with the strtoul() family was "fixed" by breaking the kernel versions to take a `const char **endptr' instead of a `char *endptr' and propagating the breakage to all callers. This should be backed out. The warning can be avoided using a union hack. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901291349.AAA06463>