bug-gnulib
[Top][All Lists]
Advanced

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

argp: fix __restrict for older compilers


From: Bruno Haible
Subject: argp: fix __restrict for older compilers
Date: Sun, 25 Mar 2007 19:53:30 +0200
User-agent: KMail/1.5.4

On BeOS, which has a gcc compiler older than 2.95, one gets syntax errors
in gnulib's <string.h> due to 'restrict'. The reason is that
  - configure does a "#define restrict __restrict", since gcc supports that
    keyword.
  - argp.h does "#define __restrict restrict", since it sees that 'restrict'
    is defined as a macro.
  - The uses of 'restrict' in <string.h> expand to 'restrict', according to
    ANSI C. But gcc does not support 'restrict'; this is why configure had
    defined it in the first place.

One could use an alternate keyword, such as '_Restrict_', as done in
regex.h, but there are dozens of occurrences of '__restrict' which would need
to be changed. It's less intrusive the define '__restrict' to a different
value. I'm applying this:


2007-03-25  Bruno Haible  <address@hidden>

        * lib/argp.h (__restrict): Define to empty, rather than to 'restrict',
        if the compiler does not support C99.

--- lib/argp.h  28 Dec 2006 23:36:43 -0000      1.16
+++ lib/argp.h  25 Mar 2007 17:37:41 -0000
@@ -1,5 +1,5 @@
 /* Hierarchial argument parsing, layered over getopt.
-   Copyright (C) 1995-1999,2003-2006 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999,2003-2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <address@hidden>.
 
@@ -49,10 +49,12 @@
 #endif
 
 /* GCC 2.95 and later have "__restrict"; C99 compilers have
-   "restrict", and "configure" may have defined "restrict".  */
+   "restrict", and "configure" may have defined "restrict".
+   Other compilers use __restrict, __restrict__, and _Restrict, and
+   'configure' might #define 'restrict' to those words.  */
 #ifndef __restrict
 # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
-#  if defined restrict || 199901L <= __STDC_VERSION__
+#  if 199901L <= __STDC_VERSION__
 #   define __restrict restrict
 #  else
 #   define __restrict





reply via email to

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