How to include the header files effectively - Mailing list pgsql-hackers

From Andy Fan
Subject How to include the header files effectively
Date
Msg-id CAKU4AWoSxnRXTiEuEiDWgizS1LR53ifD63tLYmLGP8gbirz7cw@mail.gmail.com
Whole thread Raw
Responses Re: How to include the header files effectively
Re: How to include the header files effectively
List 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

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Should we add GUCs to allow partition pruning to be disabled?
Next
From: Tom Lane
Date:
Subject: Re: How to include the header files effectively