Re: const correctness

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: const correctness
Дата
Msg-id 4EBABD140200002500042C60@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: const correctness  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> In general I don't have an objection to adding "const" to
> individual routines, so long as it doesn't create propagating
> requirements to const-ify other code.  This may be the only way to
> do it.
As I understand it (although I'm no C expert), a "const" qualifier
on a function parameter declaration is a promise that the function
will not modify what is thus qualified.  That means that it can't
pass a const parameter to another function as a parameter not also
declared const.  It doesn't say anything about the object itself or
what is returned from the function.
So a non-const parameter in can be passed to a const parameter in a
call, but not vice versa.  And a variable need not be declared const
to pass it to a function as a const parameter.  I don't know if this
meets your conditions for non-propagation.
-Kevin


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

Предыдущее
От: José Arthur Benetasso Villanova
Дата:
Сообщение: Re: [patch] Include detailed information about a row failing a CHECK constraint into the error message
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: 9.1.2 ?