On Feb 28 2004, Andras Erdei wrote:
> the reason you felt you need the circles is that sometimes
> a.h needs an incomplete type from b.h and at the same time
> b.h really depends on a.h
>=20
> this is why runlist.h forward declares runlist_element and
> runlist before including attrib.h: attrib.h needs incomplete
> types from runlist.h, and runlist.h depends on attrib.h; but
> you still had to handcode that into runlist.h because circular
> includes don't really solve this problem (1 & 2 means they
> don't do anything at all when they compile)
Correct.
=20
> volume.h similarly forward declares ntfs_volume before including
> other headers; i haven't got further yet :O)
>=20
> using handcoded forward declarations is one option, but afaik
> the canonical (pretty) solution is to provide separate forward
> declaration headers, like
>=20
> runlist_fwd.h:
> typedef struct _runlist_element runlist_element;
> typedef runlist_element runlist;
>=20
> attrib.h:
> #include "runlist_fwd.h"=09<-- instead of "runlist.h"
> ...
>=20
> handcoding the forward declarations into the header
> is perfectly o.k. (although the right place is attrib.h,
> not runlist.h), but having a forwarding header means
I don't want to forward declare runlist stuff in attrib.h. Bound to cause=
=20
headaches later on when somethin in runlist.h gets modified and we have to=
=20
hunt all the other forward declarations. This is why the includes are=20
circular and use header guards.
> - slightly less maintenance (only one file has to be
> edited when e.g. you add a new type to runlist.h)
>=20
> - slightly faster compilation (user code that only
> needs the incomplete type can also include the _fwd.h
> instead of the real one)
>=20
> - imho a bit more clarity
I agree. Would you like to send me patches doing the _fwd.h thing?
Best regards,
Anton
--=20
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
|