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

Zongze Yang yangzongze at gmail.com
Tue Apr 18 09:41:37 CDT 2023


The value of PETSC_C_VERSION = 17. I changed  `PETSC_C_VERSION >= 17`
to   `PETSC_C_VERSION
> 17`, then the error is gone.

Best wishes,
Zongze


On Tue, 18 Apr 2023 at 22:36, Satish Balay <balay at mcs.anl.gov> wrote:

> I think its best if configure can handle this automatically (check for
> broken compilers). Until then - perhaps we should use:
>
>
> diff --git a/include/petsc/private/vecimpl.h
> b/include/petsc/private/vecimpl.h
> index dd75dbbc00b..dd9ef6791c5 100644
> --- a/include/petsc/private/vecimpl.h
> +++ b/include/petsc/private/vecimpl.h
> @@ -110,12 +110,7 @@ struct _VecOps {
>    PetscErrorCode (*setvaluescoo)(Vec, const PetscScalar[], InsertMode);
>  };
>
> -#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 11))
> -  #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>
> -  #endif
> -
> +#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 17))
>  static_assert(offsetof(struct _VecOps, duplicate) == sizeof(void
> (*)(void)) * VECOP_DUPLICATE, "");
>  static_assert(offsetof(struct _VecOps, set) == sizeof(void (*)(void)) *
> VECOP_SET, "");
>  static_assert(offsetof(struct _VecOps, view) == sizeof(void (*)(void)) *
> VECOP_VIEW, "");
>
>
> Or just:
>
> +#if defined(offsetof) && defined(__cplusplus)
>
> 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
> > > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230418/e95470d8/attachment.html>


More information about the petsc-users mailing list