bug-gnulib
[Top][All Lists]
Advanced

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

Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++


From: Bruno Haible
Subject: Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++
Date: Wed, 25 Oct 2006 15:11:17 +0200
User-agent: KMail/1.9.1

Paul Eggert wrote:
> However, gettext.h does attempt to be portable to C++, so the problems
> you found there suggest that a fix is needed.  It currently does this:
> 
>   #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
>     (__GNUC__ >= 3 || defined __cplusplus)
> 
> but (as you've found) older C++ compilers define __cplusplus without
> having variable-length arrays.  Also, many C compilers other than GCC
> have variable length arrays, and don't need to be penalized.
> 
> Bruno, how about this patch?
> 
> 2006-10-24  Paul Eggert  <address@hidden>
> 
>       * lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Remove.
>       All uses replaced by HAVE_C_VARARRAYS.
>       * modules/gettext-h: Depend on vararrays.

I cannot use this, because gettext.h is documented in the GNU gettext manual
and therefore meant to be used outside the context of gnulib. I could add
the invocation to AC_C_VARARRAYS to gettext.m4, but this doesn't seem right
either.

So gettext.h needs to contains a standalone approximation of what the
autoconf test would determine. I'm applying this.

*** lib/gettext.h       17 Oct 2006 12:07:03 -0000      1.2
--- lib/gettext.h       25 Oct 2006 13:04:32 -0000
***************
*** 164,171 ****
  
  #include <string.h>
  
  #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
!   (__GNUC__ >= 3 || defined __cplusplus)
  
  #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
  #include <stdlib.h>
--- 164,175 ----
  
  #include <string.h>
  
+ /* GCC supports variable-size arrays in C and C++ mode.
+    ISO C++ supports variable-size arrays, but some older PGI and Sun compilers
+    don't.  */
  #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
!   (__GNUC__ >= 3 \
!    || (defined __cplusplus && !(defined __PGI || defined __SUNPRO_CC)))
  
  #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
  #include <stdlib.h>

The failure with "g++ -pedantic" will stay; failures obtained with -pedantic,
like -Werror, can be avoided by not using this option.

Bruno




reply via email to

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