Gisle Vanem wrote:
The new files libc-config.h and cdefs.h, break MSVC in
several ways:
1) libc-config.h:
# undef __inline
'__inline' is a built-in reserved word used through-out the MS SDK.
'#undef X' is merely a preprocessor directive; it doesn't affect whether X is
treated as a reserved word. So why is this a problem?
Hmm, is it because of the '#define __inline' to nothing later on? OK, I can see
where that might be an issue. Should be fixed in the attached patch, which I
installed into Gnulib.
2) MSVC doesn't accept this:
#define libc_hidden_proto(name, attrs...)
Why not simply?
#define libc_hidden_proto(name, ...)
Thanks, that was merely a cut-and-paste from glibc, which can assume the GNU C
extension of a name for the "...", and where I didn't notice the assumption.
This also should be fixed in the attached patch.
I haven't tested this with MSVC since I don't use MSVC, so please give it a try.
PS. You write "several ways" but mention only 2 ways; are there other things
that need fixing?
From 86814dca654fdefb66989808dbe75502d742fd47 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 5 Sep 2017 23:32:59 -0700
Subject: [PATCH] libc-config: port to MSVC
Problems reported by Gisle Vanem in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-09/msg00016.html
* lib/libc-config.h (__inline): Don't define if HAVE___INLINE.
(libc_hidden_proto): Stick to Standard C syntax for varargs macro.
* m4/__inline.m4: New file.
* modules/libc-config (Files): Add it.
(Depends-on): Use it.
---
ChangeLog | 9 +++++++++
lib/libc-config.h | 6 +++---
m4/__inline.m4 | 22 ++++++++++++++++++++++
modules/libc-config | 2 ++
4 files changed, 36 insertions(+), 3 deletions(-)
create mode 100644 m4/__inline.m4
diff --git a/ChangeLog b/ChangeLog
index 448bad2..63eb16d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2017-09-05 Paul Eggert <egg...@cs.ucla.edu>
+ libc-config: port to MSVC
+ Problems reported by Gisle Vanem in:
+ http://lists.gnu.org/archive/html/bug-gnulib/2017-09/msg00016.html
+ * lib/libc-config.h (__inline): Don't define if HAVE___INLINE.
+ (libc_hidden_proto): Stick to Standard C syntax for varargs macro.
+ * m4/__inline.m4: New file.
+ * modules/libc-config (Files): Add it.
+ (Depends-on): Use it.
+
glob: Use enum for __glob_pattern_type result
From a patch proposed by Adhemerval Zanella in:
https://sourceware.org/ml/libc-alpha/2017-09/msg00212.html
diff --git a/lib/libc-config.h b/lib/libc-config.h
index 2ebb875..93a8db0 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -150,8 +150,8 @@
/* <cdefs.h> __inline is too pessimistic for non-GCC. */
#undef __inline
-#ifndef __GNUC__
-# if 199901 <= __STDC_VERSION__
+#ifndef HAVE___INLINE
+# if 199901 <= __STDC_VERSION__ || defined inline
# define __inline inline
# else
# define __inline
@@ -172,7 +172,7 @@
/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
#define attribute_hidden
-#define libc_hidden_proto(name, attrs...)
+#define libc_hidden_proto(name, ...)
#define libc_hidden_def(name)
#define libc_hidden_weak(name)
#define libc_hidden_ver(local, name)
diff --git a/m4/__inline.m4 b/m4/__inline.m4
new file mode 100644
index 0000000..95c34a9
--- /dev/null
+++ b/m4/__inline.m4
@@ -0,0 +1,22 @@
+# Test for __inline keyword
+dnl Copyright 2017 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl___INLINE],
+[
+ AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
+ [gl_cv_c___inline],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[typedef int foo_t;
+ static __inline foo_t foo (void) { return 0; }]],
+ [[return foo ();]])],
+ [gl_cv_c___inline=yes],
+ [gl_cv_c___inline=no])])
+ if test $gl_cv_c___inline = yes; then
+ AC_DEFINE([HAVE___INLINE], [1],
+ [Define to 1 if the compiler supports the keyword '__inline'.])
+ fi
+])
diff --git a/modules/libc-config b/modules/libc-config
index 8df46fe..7706165 100644
--- a/modules/libc-config
+++ b/modules/libc-config
@@ -4,10 +4,12 @@ System definitions for code taken from the GNU C Library
Files:
lib/cdefs.h
lib/libc-config.h
+m4/__inline.m4
Depends-on:
configure.ac:
+gl___INLINE
Makefile.am:
--
2.7.4