[Top][All Lists]
[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: |
Paul Eggert |
Subject: |
Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++ |
Date: |
Wed, 25 Oct 2006 10:02:57 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Bruno Haible <address@hidden> writes:
+ /* 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)))
Like Ben Pfaff, I don't understand the assertion that ISO
C++ supports variable-length arrays. He checked the 1998
standard. I just now checked the 2005-10-19 working draft
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf>,
and it doesn't require support for variable length arrays
either; section 8.3.4 (page 156, the last line) says an
array size must be a constant expression.
And there's another problem, independent of C++. A portable
C program cannot use "defined" within a #define; the C
standard requires "defined" to work only when it is used
directly within #if (i.e., not as the result of a macro
expansion).
I propose the following patch; unlike my earlier patch, it
doesn't assume gnulib.
2006-10-25 Paul Eggert <address@hidden>
* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS):
Don't look at __cplusplus, since C++ does not require support
for variable length arrays. Instead, look at __STDC_VERSION__,
since ISO C99 does require them.
--- lib/gettext.h 25 Oct 2006 16:14:34 -0000 1.9
+++ lib/gettext.h 25 Oct 2006 17:00:06 -0000
@@ -164,11 +164,9 @@ npgettext_aux (const char *domain,
#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. */
+ Also, ISO C99 requires them. */
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
- (__GNUC__ >= 3 \
- || (defined __cplusplus && !(defined __PGI || defined __SUNPRO_CC)))
+ (__GNUC__ >= 3 || __STDC_VERSION__ >= 199901L)
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>
- C++ support?, Karl Berry, 2006/10/24
- gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++, Paul Eggert, 2006/10/24
- Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++, Bruno Haible, 2006/10/25
- Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++,
Paul Eggert <=
- Re: gettext.h patch for portability to sunCC, pgCC, RHEL AS 4 g++, Bruno Haible, 2006/10/25
Re: C++ support?, Bob Proulx, 2006/10/25
Re: [bug-gnulib] C++ support?, Bruno Haible, 2006/10/25