Menu

[PATCH] fix bool reserved word error in gcc 15

mark.yang
2025-04-02
2025-07-16
  • mark.yang

    mark.yang - 2025-04-02

    From: "mark.yang" mark.yang@lge.com

    • Fix build error with gcc-15.0.1
      http://errors.yoctoproject.org/Errors/Details/850147/
      srcdir/lib/util/include/bool.h:13:5: error: cannot use keyword 'false' as enumeration constant
      13 | false = 0,
      | ^~~~~
      srcdir/lib/util/include/bool.h:13:5: note: 'false' is a keyword with '-std=c23' onwards
      srcdir/lib/util/include/bool.h:15:3: error: expected ';', identifier or '(' before 'bool'
      15 | } bool;
      | ^~~~
      srcdir/lib/util/include/bool.h:15:3: warning: useless type name in empty declaration
      In file included from sleep.c:2:
      srcdir/lib/util/include/bool.h:13:5: error: cannot use keyword 'false' as enumeration constant
      13 | false = 0,
      | ^~~~~
      srcdir/lib/util/include/bool.h:13:5: note: 'false' is a keyword with '-std=c23' onwards
      srcdir/lib/util/include/bool.h:15:3: error: expected ';', identifier or '(' before 'bool'
      15 | } bool;
      | ^~~~

    gcc-15 switched to -std=c23 by default.
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

    Signed-off-by: mark.yang mark.yang@lge.com

    stable/lib/util/include/bool.h | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/stable/lib/util/include/bool.h b/stable/lib/util/include/bool.h
    index 312477c4..a5e81eb6 100644
    --- a/stable/lib/util/include/bool.h
    +++ b/stable/lib/util/include/bool.h
    @@ -9,10 +9,12 @@
    / At least the GNU compiler defines __bool_true_false_are_defined /
    #ifndef bool_true_false_are_defined
    #define __bool_true_false_are_defined
    +#if defined __STDC
    && defined STDC_VERSION && STDC_VERSION <= 201710L
    typedef enum {
    false = 0,
    true = 1
    } bool;
    #endif
    #endif
    +#endif

     

Log in to post a comment.

MongoDB Logo MongoDB