Skip to content

Compilation error in timing lib with recent compiler #4902

@bartgol

Description

@bartgol

I ran into this error

/home/runner/work/E3SM/E3SM/e3sm/source/components/homme/utils/cime/CIME/non_py/src/timing/private.h:47:15: error: cannot use keyword 'false' as enumeration constant
   47 | typedef enum {false = 0, true = 1} bool;  /* mimic C++ */
      |               ^~~~~
/home/runner/work/E3SM/E3SM/e3sm/source/components/homme/utils/cime/CIME/non_py/src/timing/private.h:47:15: note: 'false' is a keyword with '-std=c23' onwards

I was using gcc 15.2.0 in a containerized build. I think these lines

#ifndef __cplusplus
typedef enum {false = 0, true = 1} bool;  /* mimic C++ */
#endif

should be upgraded to

#if !defined(__cplusplus) && __STDC_VERSION__ < 202311L
typedef enum {false = 0, true = 1} bool;  /* mimic C++ */
#endif

Does this seem reasonable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions