]> granicus.if.org Git - nethack/commitdiff
band-aid for #H4041 - build warning: has_colors()
authorPatR <rankin@nethack.org>
Thu, 24 Jan 2019 23:25:50 +0000 (15:25 -0800)
committerPatR <rankin@nethack.org>
Thu, 24 Jan 2019 23:25:50 +0000 (15:25 -0800)
Since no one has come up with a better fix for has_colors() being
implicitly declared, add a hack for suppressing a compiler complaint
about has_colors() on linux and/or sco unix that use sufficiently old
<curses.h>.

Report was right after release of 3.6.0 but my fix at the time broke
compile when using more recent <curses.h>.

include/unixconf.h
sys/share/unixtty.c
sys/unix/Install.unx

index d5b6a72b6cd4f9c995efbce251f830d0ab6dddc8..0c42c60402a5a5729cd68893f0254f67aa7711d9 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 unixconf.h      $NHDT-Date: 1520099325 2018/03/03 17:48:45 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.30 $ */
+/* NetHack 3.6 unixconf.h      $NHDT-Date: 1548372343 2019/01/24 23:25:43 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.33 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -57,7 +57,9 @@
                         * the Makefile */
 #define TEXTCOLOR      /* Use System V r3.2 terminfo color support
                         * and/or ANSI color support on termcap systems
-                        * and/or X11 color */
+                        * and/or X11 color.  Note:  if you get compiler
+                        * warnings about 'has_colors()' being implicitly
+                        * declared, uncomment NEED_HAS_COLORS_DECL below. */
 #define POSIX_JOB_CONTROL /* use System V / Solaris 2.x / POSIX job control
                            * (e.g., VSUSP) */
 #define POSIX_TYPES /* use POSIX types for system calls and termios */
 #endif
 #endif
 
+/* Relevant for some systems which enable TEXTCOLOR:  some older versions
+   of curses (the run-time library optionally used by nethack's tty
+   interface in addition to its curses interface) supply 'has_colors()'
+   but corresponding <curses.h> doesn't declare it.  has_colors() is used
+   in unixtty.c by init_sco_cons() and init_linux_cons().  If the compiler
+   complains about has_colors() not being declared, try uncommenting
+   NEED_HAS_COLORS_DECL.  If the linker complains about has_colors not
+   being found, switch to ncurses() or update to newer version of curses. */
+/* #define NEED_HAS_COLORS_DECL */
+
 #ifdef hc /* older versions of the MetaWare High-C compiler define this */
 #ifdef __HC__
 #undef __HC__
index 39a859e7998adcf27b9094473c60b1bd7ae07417..dafbc8f44bf4a17b04ed9c28daf149be794c844d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 unixtty.c       $NHDT-Date: 1450916700 2015/12/24 00:25:00 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.21 $ */
+/* NetHack 3.6 unixtty.c       $NHDT-Date: 1548372343 2019/01/24 23:25:43 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.25 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -122,6 +122,18 @@ struct tchars inittyb2, curttyb2;
 
 #endif /* V7 */
 
+/*
+ * Old curses.h relied on implicit declaration of has_colors().
+ * Modern compilers tend to warn about implicit declarations and
+ * modern curses.h declares has_colors() explicitly.  However, the
+ * declaration it uses is not one we can simply clone (requires
+ * <stdbool.h>).  This simpler declaration suffices but can't be
+ * used unconditionally because it conflicts with the 'bool' one.
+ */
+#ifdef NEED_HAS_COLORS_DECL
+int has_colors();
+#endif
+
 #if defined(TTY_GRAPHICS) && ((!defined(SYSV) && !defined(HPUX)) \
                               || defined(UNIXPC) || defined(SVR4))
 #ifndef LINT
index 6e9285100e1fb306503c384fbeedc1e82ec5242e..455e8bab58634cdc0a1aecadda420fdcfff393db 100644 (file)
@@ -95,8 +95,8 @@ the file NewInstall.unx.
                        call Joan at +1 312 555-1234.
                        email support@example.com
                        visit http://www.example.com/game-support
-       RECOVER= instructions for running recover.  If RECOVER is not available,
-               do not use this line.  Some sample values:
+       RECOVER= instructions for running recover.  If RECOVER is not
+               available, do not use this line.  Some sample values:
                        To get your game recovered, contact support.
                        Run /usr/local/bin/nh-recover to recover your game.
                        
@@ -291,6 +291,13 @@ Notes:
 
     For recover, you just want the target binary to install on the target.
 
-# NetHack 3.6  Install.unx       $NHDT-Date: 1524689449 2018/04/25 20:50:49 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.11 $
+16. If you get a compiler warning about 'get_colors()' being implicitly
+    declared, try uncommenting NEED_GET_COLORS_DECL in unixconf.h.
+    If you get a compiler complaint about tparmdecl() having conflicting
+    declarations, add '#define NOTPARMDECL' to unixconf.h or '-DNOTPARMDECL'
+    to CFLAGS in src/Makefile.  (The hints files for Mac OSX already do the
+    latter.)
+
+# NetHack 3.6  Install.unx       $NHDT-Date: 1548372344 2019/01/24 23:25:44 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.12 $
 # Copyright (c) 2012 by Kenneth Lorber, Kensington, Maryland
 # NetHack may be freely redistributed.  See license for details.