<div dir="ltr">The value of PETSC_C_VERSION = 17. I changed `<span style="color:rgb(80,0,80)">PETSC_C_VERSION >= 17` to </span>
`<span style="color:rgb(80,0,80)">PETSC_C_VERSION > 17`, then the error is gone.</span><div><font color="#500050"><br clear="all"></font><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Best wishes,<div>Zongze</div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 18 Apr 2023 at 22:36, Satish Balay <<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I think its best if configure can handle this automatically (check for broken compilers). Until then - perhaps we should use:<br>
<br>
<br>
diff --git a/include/petsc/private/vecimpl.h b/include/petsc/private/vecimpl.h<br>
index dd75dbbc00b..dd9ef6791c5 100644<br>
--- a/include/petsc/private/vecimpl.h<br>
+++ b/include/petsc/private/vecimpl.h<br>
@@ -110,12 +110,7 @@ struct _VecOps {<br>
PetscErrorCode (*setvaluescoo)(Vec, const PetscScalar[], InsertMode);<br>
};<br>
<br>
-#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 11))<br>
- #if (PETSC_C_VERSION >= 11) && (PETSC_C_VERSION < 23)<br>
- // static_assert() is a keyword since C23, before that defined as macro in assert.h<br>
- #include <assert.h><br>
- #endif<br>
-<br>
+#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 17))<br>
static_assert(offsetof(struct _VecOps, duplicate) == sizeof(void (*)(void)) * VECOP_DUPLICATE, "");<br>
static_assert(offsetof(struct _VecOps, set) == sizeof(void (*)(void)) * VECOP_SET, "");<br>
static_assert(offsetof(struct _VecOps, view) == sizeof(void (*)(void)) * VECOP_VIEW, "");<br>
<br>
<br>
Or just:<br>
<br>
+#if defined(offsetof) && defined(__cplusplus)<br>
<br>
Satish<br>
<br>
On Tue, 18 Apr 2023, Jacob Faibussowitsch wrote:<br>
<br>
> This is a bug in GCC 9. Can you try the following:<br>
> <br>
> $ make clean<br>
> $ make CFLAGS+='-std=gnu11’<br>
> <br>
> Best regards,<br>
> <br>
> Jacob Faibussowitsch<br>
> (Jacob Fai - booss - oh - vitch)<br>
> <br>
> > On Apr 18, 2023, at 10:07, Zongze Yang <<a href="mailto:yangzongze@gmail.com" target="_blank">yangzongze@gmail.com</a>> wrote:<br>
> > <br>
> > No, it doesn't. It has the same problem. I just `make clean` and the `make`. Do I need to reconfigure?<br>
> > <br>
> > Best wishes,<br>
> > Zongze<br>
> > <br>
> > <br>
> > On Tue, 18 Apr 2023 at 21:09, Satish Balay <<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>> wrote:<br>
> > Does this change work?<br>
> > <br>
> > diff --git a/include/petsc/private/vecimpl.h b/include/petsc/private/vecimpl.h<br>
> > index dd75dbbc00b..168540b546e 100644<br>
> > --- a/include/petsc/private/vecimpl.h<br>
> > +++ b/include/petsc/private/vecimpl.h<br>
> > @@ -110,7 +110,7 @@ struct _VecOps {<br>
> > PetscErrorCode (*setvaluescoo)(Vec, const PetscScalar[], InsertMode);<br>
> > };<br>
> > <br>
> > -#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 11))<br>
> > +#if defined(offsetof) && (defined(__cplusplus) || (PETSC_C_VERSION >= 17))<br>
> > #if (PETSC_C_VERSION >= 11) && (PETSC_C_VERSION < 23)<br>
> > // static_assert() is a keyword since C23, before that defined as macro in assert.h<br>
> > #include <assert.h><br>
> > <br>
> > <br>
> > Satish<br>
> > <br>
> > On Tue, 18 Apr 2023, Zongze Yang wrote:<br>
> > <br>
> > > Hi, I am building petsc using gcc@9.5.0, and found the following error:<br>
> > > <br>
> > > ```<br>
> > > In file included from /usr/include/alloca.h:25,<br>
> > > from /usr/include/stdlib.h:497,<br>
> > > from<br>
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petscsys.h:1395,<br>
> > > from<br>
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petscsf.h:7,<br>
> > > from<br>
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/src/vec/is/sf/interface/vscat.c:1:<br>
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petsc/private/vecimpl.h:124:15:<br>
> > > error: expected declaration specifiers or '...' before '__builtin_offsetof'<br>
> > > 124 | static_assert(offsetof(struct _VecOps, loadnative) == sizeof(void<br>
> > > (*)(void)) * VECOP_LOADNATIVE, "");<br>
> > > | ^~~~~~~~<br>
> > > In file included from<br>
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/src/vec/is/sf/interface/vscat.c:7:<br>
> > > /home/lrtfm/opt/firedrake/complex-int32/petsc/include/petsc/private/vecimpl.h:124:98:<br>
> > > error: expected declaration specifiers or '...' before string constant<br>
> > > 124 | static_assert(offsetof(struct _VecOps, loadnative) == sizeof(void<br>
> > > (*)(void)) * VECOP_LOADNATIVE, "");<br>
> > > |<br>
> > > ^~<br>
> > > ```<br>
> > > <br>
> > > Could someone give me some hints to fix it? The configure.log and make.log<br>
> > > are attached.<br>
> > > <br>
> > > <br>
> > > Best wishes,<br>
> > > Zongze<br>
> > > <br>
> > <br>
> <br>
</blockquote></div>