X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EAF92D1B2A6 for ; Wed, 9 Jun 2004 19:21:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71069-03 for ; Wed, 9 Jun 2004 22:21:16 +0000 (GMT) Received: from smtp-out4.xs4all.nl (smtp-out4.xs4all.nl [194.109.24.5]) by svr1.postgresql.org (Postfix) with ESMTP id A840ED1B18A for ; Wed, 9 Jun 2004 19:21:12 -0300 (ADT) Received: from xs1.xs4all.nl (xs1.xs4all.nl [194.109.21.2]) by smtp-out4.xs4all.nl (8.12.10/8.12.10) with ESMTP id i59MLF34056835; Thu, 10 Jun 2004 00:21:15 +0200 (CEST) Received: from xs1.xs4all.nl (jtv@localhost.xs4all.nl [127.0.0.1]) by xs1.xs4all.nl (8.12.10/8.12.10) with ESMTP id i59MLFfr017719; Thu, 10 Jun 2004 00:21:15 +0200 (CEST) (envelope-from jtv@xs4all.nl) Received: (from jtv@localhost) by xs1.xs4all.nl (8.12.10/8.12.9/Submit) id i59MLEsf017716; Thu, 10 Jun 2004 00:21:14 +0200 (CEST) (envelope-from jtv) Date: Thu, 10 Jun 2004 00:21:14 +0200 From: "Jeroen T. Vermeulen" To: David Stanaway Cc: pgsql-interfaces@postgresql.org Subject: Re: Problem with PQexecPrepared Message-ID: <20040609222114.GI91662@xs4all.nl> Mail-Followup-To: David Stanaway , pgsql-interfaces@postgresql.org References: <1086817452.10544.5.camel@dmxnocws13.dialmex.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1086817452.10544.5.camel@dmxnocws13.dialmex.net> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/21 X-Sequence-Number: 4949 On Wed, Jun 09, 2004 at 04:44:12PM -0500, David Stanaway wrote: > The type I am passing is a char** and it is expecting const char* const* I'm not sure I understand your question entirely, so forgive me if I'm telling you things you already know... The C type system needs to be strict here to guard against the case where people try pass a "char **" argument to a "const char **" parameter. Why is that a problem? Because the function might try to insert a "const char *" into the array, thinking it got passed an array of "const char *"s. But after the function returned, the caller might overwrite the actual string this pointer pointed to because it never told the function that the chars were to be kept const. This is a case where "adding a const" is not type-safe. Not that it would be a problem here, because the array itself is const and so the function could never write its own pointer into it. I think it's one of those rare situations where a cast is justified. > The parameters I am passing in a generated at runtime so I can supply a > const pointer. Generating something at runtime doesn't mean you can't have a const pointer to it. Declaring the thing a pointer points to "const" is a promise that you won't use the pointer to modify that thing. Which doesn't mean that it can't be modified through another pointer! Jeroen