Re: [HACKERS] Adding some const keywords to external interfaces

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: darcy(at)druid(dot)net (D'ArcyJ(dot)M(dot)Cain), pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Adding some const keywords to external interfaces
Date: 1999-02-05 04:11:45
Message-ID: 15310.918187905@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Um, I hate to say "I told you so", but this const-addition has
in fact created more warning messages than it eliminated:

gcc -I../../interfaces/libpq -I../../include -I../../backend -g -O -Wall -Wmissing-prototypes -c psql.c -o psql.o
psql.c: In function `HandleSlashCmds':
psql.c:1833: warning: passing arg 1 of `free' discards `const' from pointer target type
psql.c:2192: warning: passing arg 1 of `free' discards `const' from pointer target type
psql.c:2257: warning: passing arg 1 of `free' discards `const' from pointer target type
psql.c:2265: warning: passing arg 1 of `free' discards `const' from pointer target type
psql.c:2309: warning: passing arg 1 of `free' discards `const' from pointer target type
psql.c: In function `main':
psql.c:2982: warning: passing arg 1 of `free' discards `const' from pointer target type

I think this is a fairly graphic demonstration of my assertion that
adding const to application-visible fields is not entirely transparent.

I would like to back this patch out until such time as we are prepared
to fully const-ify libpq's interface (eg, declare PQgetvalue and all
the other accessor functions as returning const char* not just char*).
We shouldn't annoy application programmers a little bit here and a
little bit there --- we should go the whole nine yards at once rather
than forcing them to insert a few more "const"s with each release.
IMHO, anyway.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-02-05 04:26:36 Re: [HACKERS] Adding some const keywords to external interfaces
Previous Message Bruce Momjian 1999-02-05 03:38:06 Re: [HACKERS] DEC OSF1 Compilation problems