bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: libintl.h warnings with -Wundef


From: Bruno Haible
Subject: Re: libintl.h warnings with -Wundef
Date: Sat, 20 Sep 2008 14:00:18 +0200
User-agent: KMail/1.5.4

Ralf Wildenhues wrote:
> > This -Wundef option is pointless:
> 
> >   - Is its purpose to detect typos? No ...
> 
> I would use "defined X && X" only for those identifiers which may well
> be undefined, like those that come from the system, compiler, or from a
> generated config.h file.  For others, where I know the identifier is
> defined, but I would like to distinguish between its value (e.g. because
> they are defined by my package header), a typo warning is helpful.

Point taken. If someone works like this, -Wundef is useful for him.

This coding style will not work in combination with gnulib (because in
gnulib we use X also when X may not be defined), will be tedious for
people who use autoconf (because there are many X that are defined or
not defined in config.h) and be otherwise strange: who does copy&paste
for macros listed in config.h but retypes by hand the macros defined
in his package header?

But anyway, your argument is theoretically correct. I'm applying this:


2008-09-20  Bruno Haible  <address@hidden>

        * libgnuintl.h.in: Use (defined X && X) idiom to test whether a
        possibly undefined macro has a certain value. Pacifies users of the
        gcc option -Wundef.
        Reported by Christian Weisgerber <address@hidden> and
        Ralf Wildenhues <address@hidden>.

--- libgnuintl.h.in     28 Nov 2007 14:19:06 -0000      1.24
+++ libgnuintl.h.in     20 Sep 2008 11:49:00 -0000
@@ -1,5 +1,5 @@
 /* Message catalogs for internationalization.
-   Copyright (C) 1995-1997, 2000-2007 Free Software Foundation, Inc.
+   Copyright (C) 1995-1997, 2000-2008 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published
@@ -88,7 +88,7 @@
    If he doesn't, we choose the method.  A third possible method is
    _INTL_REDIRECT_ASM, supported only by GCC.  */
 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
-# if __GNUC__ >= 2 && !(__APPLE_CC__ > 1) && !defined __MINGW32__ && 
!(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
+# if defined __GNUC__ && __GNUC__ >= 2 && !(defined __APPLE_CC__ && 
__APPLE_CC__ > 1) && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) 
&& (defined __STDC__ || defined __cplusplus)
 #  define _INTL_REDIRECT_ASM
 # else
 #  ifdef __cplusplus
@@ -110,7 +110,7 @@
 /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
    its n-th argument literally.  This enables GCC to warn for example about
    printf (gettext ("foo %y")).  */
-#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
+#if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && 
__APPLE_CC__ > 1 && defined __cplusplus)
 # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
 #else
 # define _INTL_MAY_RETURN_STRING_ARG(n)
@@ -316,7 +316,7 @@
 #include <stddef.h>
 
 /* Get va_list.  */
-#if __STDC__ || defined __cplusplus || defined _MSC_VER
+#if (defined __STDC__ && __STDC__) || defined __cplusplus || defined _MSC_VER
 # include <stdarg.h>
 #else
 # include <varargs.h>





reply via email to

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