Re: Walker/mutator prototype.

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Walker/mutator prototype.
Дата
Msg-id 87n09vuyt7.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Re: Walker/mutator prototype.  (Kurt Roeckx <Q@ping.be>)
Ответы Re: Walker/mutator prototype.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Kurt Roeckx <Q@ping.be> writes:

> I did start by changing all the context's to void *, but you'll
> loose the real type that it gets called with, so the other calls
> will not generate warnings anymore because of wrong type.  

But at least you'll get a warning if someone passes a non-pointer or an
incorrect number of arguments altogether.

> So I just casted the function pointers to the right type.

But that means you'll *never* get a warning. Even if someone passes a function
that's completely inappropriate. That seems worse than the disease. 

Plus it's simply wrong since the compiler might actually invoke the function
incorrectly. When you call the function you have to call it through a function
pointer with the same type as the prototype the function was defined with to
guarantee all the casts are performed and the proper calling convention is
followed.

-- 
greg



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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: ORDER BY and DISTINCT ON
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [PATCHES] fork/exec patch