Date: Fri, 7 Sep 2001 02:19:18 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Mark Murray <mark@grondar.za> Cc: Maxim Sobolev <sobomax@FreeBSD.org>, Mark Murray <markm@FreeBSD.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org> Subject: Re: cvs commit: src/usr.bin/su Makefile su.c Message-ID: <20010907015343.K32058-100000@alphplex.bde.org> In-Reply-To: <200109051017.f85AH2k99078@grimreaper.grondar.za>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 5 Sep 2001, Mark Murray wrote: > > > markm 2001/09/04 10:10:57 PDT > > > > > >[...] > > > > > > This solves the problem (in my own mind) of how a "const char *" _ever_ > > > actually gets a value in a WARNS=2 world. > > > > const char *foo = "bar"; ??? > > Right :-). > > Now how do you get (variable) stuff into a 'const char *'? /* Initialize `foo' in its declaration would be a style bug. */ const char *foo; ... foo = variable_stuff(); /* What's the problem? */ > For example - a function is not allowed to modify its arguments, so > they are const, but the stuff being passed in is by no means constant. > That one is easy - you can pass a 'foo *' into a 'const foo *'. Now, Initializing the "const char *" is easy because it is essentially the same as this. > how do you build up a 'const foo *' in such a way that you can, but > nobody else can? This question is sort of backwards too. You want to get const non-built-up stuff into a plain "char *". > Like perl's un-tainting, C needs a formal un-consting, and I guess > this is it. It's just a cast to non-const in ISO C. gcc -Wcast-qual emits warnings that some would consider spurious. But you asked for them by setting WARNS=2. 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?20010907015343.K32058-100000>