Summary
With GCC 15 (which defaults to C23), ./configure reports checking for stdbool.h that conforms to C99... no. As a result HAVE_STDBOOL_H is never defined and test/common/testutils.h falls back to enum {false=0, true=1};, which is a hard error when the header is included from C++ in test/CXX:
In file included from nctst.cpp:20:
./../common/testutils.h:26:7: error: expected identifier before 'false'
26 | enum {false=0, true=1};
Seen with PnetCDF 1.15.1 (also affects 1.15.0) on Linux x86_64 and aarch64 with GCC 15 and MPICH 5, OpenMPI 5 and MVAPICH, while building the conda-forge package (conda-forge/libpnetcdf-feedstock#14). The same fallback is present in src/utils/ncmpidump/ncmpidump.h, so ncmpidump is silently built with typedef int boolean instead of <stdbool.h> under C23 as well.
Cause
The shipped configure is generated by Autoconf 2.71, whose AC_HEADER_STDBOOL test contains #ifndef bool / #error "bool is not defined" for non-C++ compilers. In C23, bool, true and false are keywords rather than macros, so the test fails even though <stdbool.h> is fully conforming. Autoconf 2.72 fixed this test. The check can be reproduced by compiling the conftest.c from the configure log with gcc -std=gnu2x.
Suggested fixes
- Regenerate
configure with Autoconf >= 2.72, and/or
- Make the fallback in
testutils.h and ncmpidump.h robust: skip the enum when __cplusplus is defined (C++ already has true/false), e.g. #if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L).
Workaround
Passing ac_cv_header_stdbool_h=yes in the environment when running ./configure restores the intended behaviour.
Summary
With GCC 15 (which defaults to C23),
./configurereportschecking for stdbool.h that conforms to C99... no. As a resultHAVE_STDBOOL_His never defined andtest/common/testutils.hfalls back toenum {false=0, true=1};, which is a hard error when the header is included from C++ intest/CXX:Seen with PnetCDF 1.15.1 (also affects 1.15.0) on Linux x86_64 and aarch64 with GCC 15 and MPICH 5, OpenMPI 5 and MVAPICH, while building the conda-forge package (conda-forge/libpnetcdf-feedstock#14). The same fallback is present in
src/utils/ncmpidump/ncmpidump.h, soncmpidumpis silently built withtypedef int booleaninstead of<stdbool.h>under C23 as well.Cause
The shipped
configureis generated by Autoconf 2.71, whoseAC_HEADER_STDBOOLtest contains#ifndef bool/#error "bool is not defined"for non-C++ compilers. In C23,bool,trueandfalseare keywords rather than macros, so the test fails even though<stdbool.h>is fully conforming. Autoconf 2.72 fixed this test. The check can be reproduced by compiling theconftest.cfrom the configure log withgcc -std=gnu2x.Suggested fixes
configurewith Autoconf >= 2.72, and/ortestutils.handncmpidump.hrobust: skip theenumwhen__cplusplusis defined (C++ already hastrue/false), e.g.#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L).Workaround
Passing
ac_cv_header_stdbool_h=yesin the environment when running./configurerestores the intended behaviour.