bug-readline
[Top][All Lists]
Advanced

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

Problem compiling Readline 7.0 with MinGW


From: Eli Zaretskii
Subject: Problem compiling Readline 7.0 with MinGW
Date: Thu, 19 Dec 2019 16:56:04 +0200

Hi,

As part of building the GDB 9.0.90 pretest with mingw.org's MinGW on
MS-Windows, I've built the copy of Readline 7.0 which is part of the
GDB distribution, and found a compilation problem:

     gcc -c  -DHAVE_CONFIG_H   -I. -I../../../gdb-9.0.90/readline/readline  
-DRL_LIBRARY_VERSION='"8.0"' -O2 -gdwarf-4 -g3 -D__USE_MINGW_ACCESS 
../../../gdb-9.0.90/readline/readline/colors.c
     In file included from ../../../gdb-9.0.90/readline/readline/colors.c:37:
     ../../../gdb-9.0.90/readline/readline/colors.c: In function 
'_rl_print_color_indicator':
     ../../../gdb-9.0.90/readline/readline/posixstat.h:140:29: error: 'S_IXGRP' 
undeclared (first use in this function); did you mean 'S_IXUSR'?
      #define S_IXUGO  (S_IXUSR | S_IXGRP | S_IXOTH)
                                  ^~~~~~~
     ../../../gdb-9.0.90/readline/readline/colors.c:203:28: note: in expansion 
of macro 'S_IXUGO'
                else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
                                 ^~~~~~~
     ../../../gdb-9.0.90/readline/readline/posixstat.h:140:29: note: each 
undeclared identifier is reported only once for each function it appears in
      #define S_IXUGO  (S_IXUSR | S_IXGRP | S_IXOTH)
                                  ^~~~~~~
     ../../../gdb-9.0.90/readline/readline/colors.c:203:28: note: in expansion 
of macro 'S_IXUGO'
                else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
                                 ^~~~~~~
     ../../../gdb-9.0.90/readline/readline/posixstat.h:140:39: error: 'S_IXOTH' 
undeclared (first use in this function); did you mean 'S_IFMT'?
      #define S_IXUGO  (S_IXUSR | S_IXGRP | S_IXOTH)
                                            ^~~~~~~
     ../../../gdb-9.0.90/readline/readline/colors.c:203:28: note: in expansion 
of macro 'S_IXUGO'
                else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
                                 ^~~~~~~
     ../../../gdb-9.0.90/readline/readline/colors.c:218:23: error: 'S_IWOTH' 
undeclared (first use in this function); did you mean 'S_IFMT'?
                if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
                            ^~~~~~~
                            S_IFMT
     Makefile:104: recipe for target `colors.o' failed

These problems happen because readline/posixstat.h uses preprocessor
macros like S_IWOTH and S_IXOTH, which are not defined on MinGW
headers.  The posixstat.h file assumes that if S_IRXWU is defined, so
are the rest of the macros, but MinGW defines only the "user" mode
bits and leaves the "group" and "other" bits undefined.  I propose
below a patch that fixes that.

--- readline/readline/posixstat.h~0     2019-11-19 03:10:41.000000000 +0200
+++ readline/readline/posixstat.h       2019-12-16 09:15:52.106496900 +0200
@@ -132,6 +132,26 @@
 #  define S_IRWXU      (S_IRUSR | S_IWUSR | S_IXUSR)
 #  define S_IRWXG      (S_IRGRP | S_IWGRP | S_IXGRP)
 #  define S_IRWXO      (S_IROTH | S_IWOTH | S_IXOTH)
+#else  /* !S_IRWXU */
+   /* S_IRWXU is defined, but "group" and "other" bits might not be
+      (happens in certain versions of MinGW).  */
+#  if !defined (S_IRGRP)
+#    define S_IRGRP    (S_IREAD  >> 3)         /* read, group */
+#    define S_IWGRP    (S_IWRITE >> 3)         /* write, group */
+#    define S_IXGRP    (S_IEXEC  >> 3)         /* execute, group */
+#  endif /* !S_IRGRP */
+
+#  if !defined (S_IROTH)
+#    define S_IROTH    (S_IREAD  >> 6)         /* read, other */
+#    define S_IWOTH    (S_IWRITE >> 6)         /* write, other */
+#    define S_IXOTH    (S_IEXEC  >> 6)         /* execute, other */
+#  endif /* !S_IROTH */
+#  if !defined (S_IRWXG)
+#    define S_IRWXG    (S_IRGRP | S_IWGRP | S_IXGRP)
+#  endif
+#  if !defined (S_IRWXO)
+#    define S_IRWXO    (S_IROTH | S_IWOTH | S_IXOTH)
+#  endif
 #endif /* !S_IRWXU */
 
 /* These are non-standard, but are used in builtins.c$symbolic_umask() */



reply via email to

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