[petsc-dev] Forward declarations of types?

Jed Brown jedbrown at mcs.anl.gov
Fri Feb 15 15:38:34 CST 2013


On Fri, Feb 15, 2013 at 12:38 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>    How does one prevent this problem?
>
> [ 15%] Building C object CMakeFiles/petsc.dir/src/ksp/pc/impls/is/nn/nn.c.o
> In file included from
> /Users/barrysmith/Src/petsc-dev/src/ksp/pc/impls/bjacobi/bjacobi.c:184:
> /Users/barrysmith/Src/petsc-dev/include/petscdraw.h:283: error:
> redefinition of typedef ‘PetscDrawLG’
> /Users/barrysmith/Src/petsc-dev/include/petscksp.h:598: error: previous
> declaration of ‘PetscDrawLG’ was here
>

Heh, I thought I remembered that duplicate typedefs were invalid in C, but
gcc happily compiled it without a warning. In fact, they _are_ allowed in
C11, but not in our old, crusty version of C.

I guess the reliable way to do this would be to have
petsc-private/${pkg}types.h that were included internally by those headers
that depend on the types, like petscksp.h. It wouldn't be user-visible, but
I'm not sure it's worthwhile.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130215/20e269bc/attachment.html>


More information about the petsc-dev mailing list