bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C23 vs NCURSES_BOOL


From: Sam James
Subject: C23 vs NCURSES_BOOL
Date: Sun, 17 Nov 2024 04:43:50 +0000
User-agent: mu4e 1.12.7; emacs 31.0.50

Hi,

Upcoming GCC 15 defaults to -std=gnu23 as of yesterday.

curses.h currently does the following:
"""
#if 0   /* __cplusplus, etc. */

/* use the C++ compiler's bool type */
#define NCURSES_BOOL bool

#else                   /* c89, c99, etc. */

#if NCURSES_ENABLE_STDBOOL_H
#include <stdbool.h>
/* use whatever the C compiler decides bool really is */
#define NCURSES_BOOL bool
#else
/* there is no predefined bool - use our own */
#undef bool
#define bool NCURSES_BOOL
#endif

#endif /* !__cplusplus, etc. */
"""

Combined with this in configure:
"""
        if test "$NCURSES_BOOL" != auto ; then
                cf_cv_type_of_bool=$NCURSES_BOOL
                cf_cv_header_stdbool_h=0
        else
                if test "$cf_cv_header_stdbool_h" = 1 ; then
                        CF_BOOL_SIZE
                else
                        AC_MSG_CHECKING(for fallback type of bool)
                        case "$host_cpu" in
                        (i?86)  cf_cv_type_of_bool=char ;;
                        (*)     cf_cv_type_of_bool=int  ;;
                        esac
                        AC_MSG_RESULT($cf_cv_type_of_bool)
                fi
        fi
"""

It looks like if stdbool.h isn't required, we end up assuming
that a native bool isn't actually available at all, but this isn't the
case in C23 where bool is natively available (and is actually the same
as _Bool) without any headers.

I noticed this when looking at a build failure with ncurses where our
packaging QA checks noticed the installed headers differed for the
32-bit and 64-bit multilib builds as:
"""
$ diff -u 
/var/tmp/portage/sys-libs/ncurses-6.5_p20241109/work/ncurses-6.5-abi_x86_32.x86/ncursest/include/curses.h
 
/var/tmp/portage/sys-libs/ncurses-6.5_p20241109/work/ncurses-6.5-abi_x86_64.amd64/ncursest/include/curses.h
--- 
/var/tmp/portage/sys-libs/ncurses-6.5_p20241109/work/ncurses-6.5-abi_x86_32.x86/ncursest/include/curses.h
   2024-11-17 04:23:22.358220380 +0000
+++ 
/var/tmp/portage/sys-libs/ncurses-6.5_p20241109/work/ncurses-6.5-abi_x86_64.amd64/ncursest/include/curses.h
 2024-11-17 04:24:51.531137819 +0000
@@ -283,7 +283,7 @@
 #undef FALSE
 #define FALSE   0

-typedef char NCURSES_BOOL;
+typedef int NCURSES_BOOL;

 #if 0  /* __cplusplus, etc. */
"""

It might be that I'm barking up the wrong tree here, but the copy on my
system is 'typedef unsigned char NCURSES_BOOL' before rebuilding with
C23.

It also seems like this manifests in a build failure of the C++ bindings
if enabled too.

Does this make sense or am I going in the wrong direction here?

thanks,
sam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]