Re: Improve node type forward reference - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Improve node type forward reference
Date
Msg-id 076ab015-9712-4c33-80f3-877b74b7ffba@eisentraut.org
Whole thread Raw
In response to Re: Improve node type forward reference  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Improve node type forward reference
Re: Improve node type forward reference
List pgsql-hackers
On 14.10.24 23:28, Nathan Bossart wrote:
> On Mon, Oct 14, 2024 at 09:47:59AM +0200, Peter Eisentraut wrote:
>> But we can do this better by using an incomplete struct, like
>>
>>          struct Query *viewQuery ...;
>>
>> That way, everything has the correct type and fewer casts are required. This
>> technique is already used elsewhere in node type definitions.
> 
> I noticed that the examples in parsenodes.h are for structs defined within
> the same file.  If the struct is defined in a separate file, I guess you
> might need to include another header file wherever it is used, but that
> doesn't seem too bad.

No, you can leave the struct incomplete.  You only need to provide its 
full definition (= include the other header file) if you actually want 
to access the struct's fields.




pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Consider the number of columns in the sort cost model
Next
From: jian he
Date:
Subject: Re: type cache cleanup improvements