[petsc-dev] Forward declarations of types?
Barry Smith
bsmith at mcs.anl.gov
Fri Feb 15 15:56:51 CST 2013
Boy they added some silly little tiny things in C11
On Feb 15, 2013, at 3:38 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>
> 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.
More information about the petsc-dev
mailing list