Return-Path: Delivered-To: new-httpd-archive@hyperreal.org Received: (qmail 23341 invoked by uid 6000); 28 Jun 1999 16:20:34 -0000 Received: (qmail 23271 invoked from network); 28 Jun 1999 16:20:32 -0000 Received: from twinlark.arctic.org (204.107.140.52) by taz.hyperreal.org with SMTP; 28 Jun 1999 16:20:32 -0000 Received: (qmail 17872 invoked by uid 500); 28 Jun 1999 16:20:29 -0000 Date: Mon, 28 Jun 1999 09:20:29 -0700 (PDT) From: Dean Gaudet To: new-httpd@apache.org Subject: Re: overloaded functions In-Reply-To: <3773AD66.6651E6A4@algroup.co.uk> Message-ID: X-Comment: Visit http://www.arctic.org/~dgaudet/legal for information regarding copyright and disclaimer. MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org On Fri, 25 Jun 1999, Ben Laurie wrote: > Dean Gaudet wrote: > > > > Oh, one thing ages back which I said was nifty in C++: > > > > char *strchr(char *, int); > > const char *strchr(const char *, int); > > > > That way you don't have to lose the "const" when you use this on a const > > string... this helps detect bugs at compile time. > > > > But gnu c gives me what I want: > > > > #ifef __GNUC__ > > #define my_strchr(a,b) ((typeof (a)) strchr((a), (b))) > > #else > > #define my_strchr strchr > > #endif > > > > ... which is good enough for most of the developers to get the warnings :) > > OK. Another one I keep bumping into is this: > > unsigned char *x,*y; > > y=strchr(x,' '); > > compiler meeps because x,y should be char *. Yes, we can do ustrchr, but > it gets messy (namewise) when you have three or more char * arguments. > > Any clever ideas for that? Nope... the typeof thing would work just fine if C required a warning for: char *y; unsigned char *x = y; ... I suppose someone could add such a warning to gcc ;) I wonder what it'd catch. ISTR such a switch existing, but can't find it right now. ("char" is a magic type in C, the implementation can decide if it's signed or unsigned...) Dean