[petsc-users] Build error: vecimpl.h:124:98: error: expected declaration specifiers or '...' before string constant

Satish Balay balay at mcs.anl.gov
Tue Apr 18 09:52:43 CDT 2023


BTW: I see this behavior with "gcc (conda-forge gcc 12.2.0-19) 12.2.0" [apart from other issues with this compiler]

And CFLAGS='-std=gnu11’ doesn't help here. This change works though..

-#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 11))
+#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 23))


Satish

On Tue, 18 Apr 2023, Jacob Faibussowitsch wrote:

> This is a bug in GCC 9. Can you try the following:
> 
> $ make clean
> $ make CFLAGS+='-std=gnu11’
> 
> Best regards,
> 
> Jacob Faibussowitsch
> (Jacob Fai - booss - oh - vitch)
> 
> > On Apr 18, 2023, at 10:07, Zongze Yang <yangzongze at gmail.com> wrote:
> > 
> > No, it doesn't. It has the same problem. I just `make clean` and the `make`. Do I need to reconfigure?
> > 
> > Best wishes,
> > Zongze
> > 
> > 
> > On Tue, 18 Apr 2023 at 21:09, Satish Balay <balay at mcs.anl.gov> wrote:
> > Does this change work?
> > 
> > diff --git a/include/petsc/private/vecimpl.h b/include/petsc/private/vecimpl.h
> > index dd75dbbc00b..168540b546e 100644
> > --- a/include/petsc/private/vecimpl.h
> > +++ b/include/petsc/private/vecimpl.h
> > @@ -110,7 +110,7 @@ struct _VecOps {
> >    PetscErrorCode (*setvaluescoo)(Vec, const PetscScalar[], InsertMode);
> >  };
> > 
> > -#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 11))
> > +#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 17))
> >    #if (PETSC_C_VERSION >= 11) && (PETSC_C_VERSION < 23)
> >      // static_assert() is a keyword since C23, before that defined as macro in assert.h
> >      #include <assert.h>
> > 
> > 
> > Satish
> > 
> > On Tue, 18 Apr 2023, Zongze Yang wrote:
> > 
> > > Hi, I am building petsc using gcc at 9.5.0, and found the following error:
> > > 
> > > ```
> > > In file included from /usr/include/alloca.h:25,
> > >                  from /usr/include/stdlib.h:497,
> > >                  from
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petscsys.h:1395,
> > >                  from
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petscsf.h:7,
> > >                  from
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/src/vec/is/sf/interface/vscat.c:1:
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petsc/private/vecimpl.h:124:15:
> > > error: expected declaration specifiers or '...' before '__builtin_offsetof'
> > >   124 | static_assert(offsetof(struct _VecOps, loadnative) == sizeof(void
> > > (*)(void)) * VECOP_LOADNATIVE, "");
> > >       |               ^~~~~~~~
> > > In file included from
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/src/vec/is/sf/interface/vscat.c:7:
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petsc/private/vecimpl.h:124:98:
> > > error: expected declaration specifiers or '...' before string constant
> > >   124 | static_assert(offsetof(struct _VecOps, loadnative) == sizeof(void
> > > (*)(void)) * VECOP_LOADNATIVE, "");
> > >       |
> > >                              ^~
> > > ```
> > > 
> > > Could someone give me some hints to fix it? The configure.log and make.log
> > > are attached.
> > > 
> > > 
> > > Best wishes,
> > > Zongze
> > > 
> > 
> 


More information about the petsc-users mailing list