[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AC_C_RESTRICT and C/C++
From: |
Bruno Haible |
Subject: |
AC_C_RESTRICT and C/C++ |
Date: |
Mon, 22 Oct 2007 02:12:37 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Paul,
Got this gettext testsuite failure with Sun C/C++ 5.0 on Solaris 10:
"../gnulib-lib/string.h", line 109: Error: ")" expected instead of "__dst".
"../gnulib-lib/string.h", line 124: Error: ")" expected instead of "__dst".
2 Error(s) detected.
FAIL: lang-c++
What's happening? gnulib's string.h replacement uses the 'restrict' keyword.
AC_C_RESTRICT has put this into config.h:
#define restrict _Restrict
The lang-c++ test has this C++ code:
#include "config.h"
...
indirectly #include <string.h>
But the definition of 'restrict' is not valid for the C++ compiler.
$ which cc
/opt/SUNWspro/SC5.0/bin/cc
$ which CC
/opt/SUNWspro/SC5.0/bin/CC
$ cat foo.c
#define restrict _Restrict
extern char *stpcpy (char *restrict __dst, char const *restrict __src);
$ cc -c foo.c; echo $?
0
$ ln foo.c foo.cc
$ CC -c foo.cc; echo $?
"foo.cc", line 2: Error: ")" expected instead of "__dst".
1 Error(s) detected.
1
This report is similar to the one for gcc / g++ in [1]. It was said in [2]
that "`restrict' is not yet a standard C++ feature."
IMO the issue would be solved if autoconf's AC_C_RESTRICT macro was changed
to emit into config.h a code like this:
/* Define to equivalent of C99 restrict keyword, or to nothing if this
is not supported. Do not define if restrict is supported directly. */
#ifdef __cplusplus
#define restrict
#else
#define restrict _Restrict
#endif
I cannot propose a patch, since I don't know how to mix AC_DEFINE and
AC_VERBATIM appropriately.
Bruno
[1] http://lists.gnu.org/archive/html/bug-autoconf/2007-05/msg00013.html
[2] http://lists.gnu.org/archive/html/bug-autoconf/2007-05/msg00016.html
- AC_C_RESTRICT and C/C++,
Bruno Haible <=