From owner-freebsd-hackers Fri Jun 8 5:49:42 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fjord.dignus.com (sdsl-66-80-58-206.dsl.lax.megapath.net [66.80.58.206]) by hub.freebsd.org (Postfix) with ESMTP id CDE8E37B408; Fri, 8 Jun 2001 05:49:36 -0700 (PDT) (envelope-from rivers@dignus.com) Received: from lakes.dignus.com (lakes.dignus.com [10.0.0.3]) by fjord.dignus.com (8.11.1/8.11.1) with ESMTP id f58CoXf99446; Fri, 8 Jun 2001 08:50:33 -0400 (EDT) (envelope-from rivers@dignus.com) Received: (from rivers@localhost) by lakes.dignus.com (8.9.3/8.6.9) id IAA49852; Fri, 8 Jun 2001 08:51:54 -0400 (EDT) Date: Fri, 8 Jun 2001 08:51:54 -0400 (EDT) From: Thomas David Rivers Message-Id: <200106081251.IAA49852@lakes.dignus.com> To: rivers@dignus.com, roam@orbitel.bg Subject: Re: free() and const warnings Cc: hackers@FreeBSD.ORG, jhb@FreeBSD.ORG In-Reply-To: <20010608154249.A7671@ringworld.oblivion.bg> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > GCC complains when I try to initialize the structure with something like: > > struct validation_fun val_init[] = { > {"init", valfun_init, 0} > }; > > This can be avoided by: > > struct validation_fun val_init[] = { > {(char *) (uintptr_t) "init", valfun_init, 0} > }; > > ..but as a matter of fact, static, pre-initialized valfun structs are > the rule rather than the exception in this program, so having this > syntax for all of them seems.. well.. ugly :) > Ah.. I see.. (I don't think you need (uintptr_t) - you can cast a (const char *) to a (char *) without having to go "through" that - I believe.) Is this C, or C++.. there are some differences in the type of a constant character string between the two... But - basically, what you are trying to describe is a field which is sometimes 'const' and othertimes isn't... which doesn't make sense in the context of the C standard... you'll need a cast for the initialization, or some other approach besides static initialization I believe... (or, just "live" with the warning... which isn't pleasant at all.) - Dave R. - -- rivers@dignus.com Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message