Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**
Дата
Msg-id 4E7921D3.7030209@ringerc.id.au
обсуждение исходный текст
Ответ на BUG #6216: Calling PQconnectdbParams from C++ with a char**  ("Lionel Elie Mamane" <lionel@mamane.lu>)
Ответы Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**
Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**
Список pgsql-bugs
On 21/09/2011 12:05 AM, Lionel Elie Mamane wrote:
> The following bug has been logged online:
>
> Bug reference:      6216
> Logged by:          Lionel Elie Mamane
> Email address:      lionel@mamane.lu
> PostgreSQL version: 9.1.0
> Operating system:   Debian GNU/Linux
> Description:        Calling PQconnectdbParams from C++ with a char**
> Details:
>
> In C++, a "char**" value is not convertible to a "const char**" value,
> because that is not safe (see
> http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17).
>
> This means one cannot call libpq's PQconnectdbParams and friends passing
> them a "char**" value for keywords and/or values, as these arguments are
> declared "const char**".
>
> So please apply this patch, which declares them "char const* const*"
> instead, which is:
>   - equivalent to "const char * const*"; use that one if you prefer

Yeah, this really annoyed me when I was working with C libraries from C++.

+1 from me; this should be applied.

Lionel: Can I get you to add the patch to the commitfest app?

https://commitfest.postgresql.org/

I'll accept review of it once you do and flag it as ready for committer
so we can streamline its inclusion.

As for wording: my *personal* preference is "const char * const" but I
don't know what the opinions of those who work with the code day-to-day are.

--
Craig Ringer

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #6216: Calling PQconnectdbParams from C++ with a char**