clang warnings
gcc -I. -c -DBINDIR=\"/usr/local/bin\" -DSYSDIR=\"/usr/local/etc\" -g -O2 option.c
screen.c:741:19: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
return (tgetflag(capname));
^~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/termcap.h:66:58: note: passing argument to parameter here
extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
^
screen.c:752:18: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
return (tgetnum(capname));
^~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/termcap.h:67:57: note: passing argument to parameter here
extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
^
screen.c:763:18: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
return (tgetstr(capname, pp));
^~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/termcap.h:63:60: note: passing argument to parameter here
extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
^
Yeah I've noticed this but I'm not yet sure how to fix it. Clearly NCURSES_CONST should be defined as "const" but for some reason that's not happening.
By the way I still using ncurses 5.4.
Hm, somehow I've updated to ncurses 5.9 and the warning is fixed because termcap.h now defines NCURSES_CONST. I don't want to check this in yet, but can you confirm whether adding this line to screen.c fixes the warnings for you?
diff --git a/screen.c b/screen.c
index 8bdf080..ea0c7be 100644
--- a/screen.c
+++ b/screen.c
@@ -68,6 +68,7 @@ extern int fd0;
#endif
#endif
+#define NCURSES_CONST const
#if HAVE_NCURSESW_TERMCAP_H
#include <ncursesw/termcap.h>
#else
still the same because of
[...]
#undef NCURSES_VERSION
#define NCURSES_VERSION "6.0"
#include <ncurses_dll.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <sys/types.h>
#undef NCURSES_CONST
#define NCURSES_CONST /*nothing*/
the header says 6.0 but the library 5.4?! https://github.com/python/cpython/issues/109617#issuecomment-1728466271
This is weird. My termcap.h has
#define NCURSES_VERSION "5.9"
#include <ncursesw/ncurses_dll.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include <sys/types.h>
#undef NCURSES_CONST
#define NCURSES_CONST const
So it seems your 6.0 termcap.h is newer than mine, but regresses to defining NCURSES_CONST as nothing, whereas my "older" 5.9 file defines it correctly. In any case, these warnings seem to be entirely caused by Apple's header files defining NCURSES_CONST incorrectly, and making it impossible to redefine it, so I'm inclined to just leave it as it is and assume that eventually Apple will get it fixed.
Indeed.
$ otool -L less
less:
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
BTW MacPorts has 6.4 5.7 without const!? https://opensource.apple.com/source/ncurses/ncurses-57/ncurses/include/termcap.h.auto.html
@gwsw It's a known issue! However we are not using CMake.