How to include the header files effectively

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: How to include the header files effectively
Date: 2019-04-12 02:08:52
Message-ID: CAKU4AWoSxnRXTiEuEiDWgizS1LR53ifD63tLYmLGP8gbirz7cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I find the dependency is complex among header files in PG. At the same
time, I find the existing code still can use the header file very
cleanly/alphabetically. so I probably missed some knowledge here.

for example, when I want the LOCKTAG in .c file, which is defined in
"storage/lock.h". then I wrote the code like this:

#include "storage/lock.h"
...

LOCKTAG tag;

compile and get errors.

In file included from
.../src/include/storage/lock.h:21:
/../../../src/include/storage/lockdefs.h:50:2: error: unknown type name
'TransactionId'
TransactionId xid; /* xid of holder of
AccessExclusiveLock */

so I HAVE TO
1. include the header file which contains the TransactionId
2. add it before the lock.h.

normally I think we can add the dependency in lock.h directly to resolve
this issue.

so how can I include header file effectively ?

Thanks

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-04-12 02:21:14 Re: How to include the header files effectively
Previous Message David Rowley 2019-04-12 02:01:39 Re: Should we add GUCs to allow partition pruning to be disabled?