Skip to content

false/true keywords in C 23 standard #224

@t-brown

Description

@t-brown

When using a new GNU compiler (15.2.0), PnetCDF fails to compile as it is using a default -std=c23, with the following error:

In file included from ncmpidump.c:22:
ncmpidump.h:19:7: error: cannot use keyword ‘false’ as enumeration constant
   19 | enum {false=0, true=1};
      |       ^~~~~
ncmpidump.h:19:7: note: ‘false’ is a keyword with ‘-std=c23’ onwards
make[3]: *** [Makefile:570: ncmpidump.o] Error 1

GCC version:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/sw/aarch64/gcc/15.2.0/libexec/gcc/aarch64-unknown-linux-gnu/15.2.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../gcc-15.2.0/configure --prefix=/sw/aarch64/gcc/15.2.0 --disable-multilib --enable-languages=c,c++,fortran
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.2.0 (GCC)

If I drop the standard to GNU 17 by adding the -std=gnu17 flag, PnetCDF will compile.

------------------------------------------------------------------------------

   PnetCDF Version 1.12.3

   Features:  Build static libraries                      - yes
              Build shared libraries                      - no
              Build Fortran APIs                          - yes
              Build C++ APIs                              - yes

   Compilers: MPICC    = /sw/aarch64/openmpi/5.0.9/bin/mpicc
              MPICXX   = /sw/aarch64/openmpi/5.0.9/bin/mpicxx
              MPIF77   = /sw/aarch64/openmpi/5.0.9/bin/mpif77
              MPIF90   = /sw/aarch64/openmpi/5.0.9/bin/mpif90
              CFLAGS   = -g -O2 -fPIC -std=gnu17
              CXXFLAGS = -g -O2 -fPIC
              FFLAGS   = -g -O2 -fPIC -fallow-argument-mismatch
              FCFLAGS  = -g -O2 -fPIC -fallow-argument-mismatch

   Now run 'make' to build the library and utility tools.
   Then run 'make [<target>]' for testing and installation, where the
   optional <target> can be:
              tests    - build all test programs (build only, no run)
              check    - run sequential test programs
              ptest    - run parallel test programs on 4 MPI processes
              ptests   - run parallel test programs on 3,4,6,8 MPI processes
              install  - install PnetCDF library in /usr/local

------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions