Skip to content

make check fails in test/CXX with GCC 15: enum {false=0, true=1} in testutils.h #240

Description

@xylar

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions