From owner-cvs-all Fri Jan 29 05:50:15 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA17991 for cvs-all-outgoing; Fri, 29 Jan 1999 05:50:15 -0800 (PST) (envelope-from owner-cvs-all@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA17962; Fri, 29 Jan 1999 05:50:10 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id AAA06463; Sat, 30 Jan 1999 00:49:58 +1100 Date: Sat, 30 Jan 1999 00:49:58 +1100 From: Bruce Evans Message-Id: <199901291349.AAA06463@godzilla.zeta.org.au> To: brian@Awfulhak.org, dillon@FreeBSD.ORG Subject: Re: cvs commit: src/sys/sys kernel.h Cc: cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk >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