bug-gnulib
[Top][All Lists]
Advanced

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

gnulib-common config.h snippet's use of _MSC_VER


From: Simon Josefsson
Subject: gnulib-common config.h snippet's use of _MSC_VER
Date: Mon, 21 Nov 2011 14:20:10 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux)

All,

The file gnulib-common contains some code that ends up in config.h and
thus gets included into all source files, and it looks like this:

#ifndef _Noreturn
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
      || 0x5110 <= __SUNPRO_C)
#  define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= _MSC_VER
#  define _Noreturn __declspec (noreturn)
# else
#  define _Noreturn
# endif
#endif

Now with -Wundef I get an error:

../../config.h:365:16: error: "_MSC_VER" is not defined

I understand that gnulib's code isn't clean against -Wundef in general,
however I believe code that gnulib puts into config.h should meet a
higher standard and be as clean as possible, to allow projects to use
whatever kind of warning parameters it choses.  So how about the patch
below?

/Simon

>From 87b3e50c8d73251e210ff4a45dca45185b7c1da9 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Mon, 21 Nov 2011 14:18:24 +0100
Subject: [PATCH 2/2] gnulib-common: Silence warnings against config.h code.

* m4/gnulib-common.m4 (_Noreturn): Check that _MSC_VER is defined
before using it, in code that ends up config.h.
---
 ChangeLog           |    5 +++++
 m4/gnulib-common.m4 |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d421257..ae86be3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-21  Simon Josefsson  <address@hidden>
+
+       * m4/gnulib-common.m4 (_Noreturn): Check that _MSC_VER is defined
+       before using it, in code that ends up config.h.
+
 2011-11-20  Bruno Haible  <address@hidden>
 
        getcwd: Work around getcwd bug on AIX 5..7.
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 7d83299..8621dec 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -18,7 +18,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
       || 0x5110 <= __SUNPRO_C)
 #  define _Noreturn __attribute__ ((__noreturn__))
-# elif 1200 <= _MSC_VER
+# elif defined _MSC_VER && 1200 <= _MSC_VER
 #  define _Noreturn __declspec (noreturn)
 # else
 #  define _Noreturn
-- 
1.7.2.5




reply via email to

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