Re: Walker/mutator prototype.

Поиск
Список
Период
Сортировка
От Kurt Roeckx
Тема Re: Walker/mutator prototype.
Дата
Msg-id 20031214133056.GA20410@ping.be
обсуждение исходный текст
Ответ на Re: Walker/mutator prototype.  (Greg Stark <gsstark@mit.edu>)
Ответы Re: Walker/mutator prototype.  (Greg Stark <gsstark@mit.edu>)
Список pgsql-hackers
On Sat, Dec 13, 2003 at 10:24:23PM -0500, Greg Stark wrote:
> Kurt Roeckx <Q@ping.be> writes:
> 
> > I'm trying to change all the walkers and mutators to have a more
> > strict prototype.  I had to do this with lots of casts.
> > 
> > I don't really like the idea of having all those generic pointer
> > types (Node * and void *), but currently see no better way to deal
> > with it.
> 
> This code is incorrect. You have to declare the function prototype to match
> the parameters that will actually be passed, not to match how they'll be used.
> 
> By casting the function pointers you're confusing the compiler into thinking
> the variables are already the correct format and don't need to be cast.
> 
> The correct way to write this type of code is to prototype the functions with
> void* or Node* or whatever variables will actually be passed, then immediately
> assign the arguments to a local variable of the correct type.

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.  So I
just casted the function pointers to the right type.

Anyway, I'll change it so that the last argument is void *
everywhere.


Kurt



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

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: ORDER BY and DISTINCT ON
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: ORDER BY and DISTINCT ON