<p dir="ltr"><br>
On Feb 15, 2013 1:01 PM, "Jed Brown" <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
><br>
> We currently use recursive includes everywhere, so petscdmda.h includes all of petscao.h just so it can declare DMDAGetAO and similar. Of course most users of (and implementation files in) DMDA do not reference AO so they don't need to know about all the AO functions.<br>
><br>
> The normal approach to this is to forward-declare the type, so instead of<br>
><br>
> #include <petscao.h> /* includes lots of other stuff */<br>
> PETSC_EXTERN PetscErrorCode DMDAGetAO(DM,AO*);<br>
><br>
> one would write<br>
><br>
> typedef struct _p_AO *AO;<br>
> PETSC_EXTERN PetscErrorCode DMDAGetAO(DM,AO*);<br>
><br>
> in which case all three files in PETSc that actually call AO routines would need to include petscao.h. That is arguably a good thing since it makes the actual dependencies more explicit, and is recommended by many (mostly C++) style guidelines.<br>
><br>
> Is this something worth considering? I think stuff like petscvec.h and petscmat.h ends up pretty much always being needed, but petscdm.h is only used by a handful of files in petscksp and above, for example.</p>
<p dir="ltr">We do this in PyLith. I like it. We need to do it in the same place in every header, with a structured comment. Should we remove the forward declaration if we end up including the full header later?</p>
<p dir="ltr"> Matt</p>
<p dir="ltr">> It might be nice to get rarely-used stuff like petscdraw.h out of petscsys.h.</p>