> Paul Eggert wrote: > > Would it suffice to append this to config.h? I don't have easy access > > to Sun C 5.0 any more (it's pretty old). > > The same issue also holds with the Sun Studio 11 compiler > (in /opt/SUNWspro/SunStudio11/SUNWspro/bin). > > Yes, this works around the issue. Thanks!
Then how about this autoconf patch? 2007-10-22 Eric Blake <[EMAIL PROTECTED]> and Paul Eggert <[EMAIL PROTECTED]> Don't define restrict for Sun C++. * lib/autoconf/c.m4 (AC_C_RESTRICT): Add verbatim block that disables definition of restrict for SunPro C++ compiler. Reported by Bruno Haible. From: Eric Blake <[EMAIL PROTECTED]> Date: Mon, 22 Oct 2007 12:10:20 -0600 Subject: [PATCH] Don't define restrict for Sun C++. * lib/autoconf/c.m4 (AC_C_RESTRICT): Add verbatim block that disables definition of restrict for SunPro C++ compiler. Reported by Bruno Haible. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> --- ChangeLog | 8 ++++++++ lib/autoconf/c.m4 | 31 ++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6827771..9be3277 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ 2007-10-22 Eric Blake <[EMAIL PROTECTED]> + and Paul Eggert <[EMAIL PROTECTED]> + + Don't define restrict for Sun C++. + * lib/autoconf/c.m4 (AC_C_RESTRICT): Add verbatim block that + disables definition of restrict for SunPro C++ compiler. + Reported by Bruno Haible. + +2007-10-22 Eric Blake <[EMAIL PROTECTED]> * doc/autoconf.texi (Particular Types): Mention bug in HP-UX 11.00 preprocessor. diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 7e2d76e..6c6da86 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -1658,28 +1658,37 @@ AN_IDENTIFIER([restrict], [AC_C_RESTRICT]) AC_DEFUN([AC_C_RESTRICT], [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, [ac_cv_c_restrict=no - # Try the official restrict keyword, then gcc's __restrict, and - # the less common variants. + # The order here caters to the fact that C++ does not require restrict. for ac_kw in __restrict __restrict__ _Restrict restrict; do AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[typedef int * int_ptr; - int foo (int_ptr $ac_kw ip) { - return ip[0]; + int foo (int_ptr $ac_kw ip) { + return ip[0]; }]], [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t)]])], + int * $ac_kw t = s; + t[0] = 0; + return foo(t)]])], [ac_cv_c_restrict=$ac_kw]) test "$ac_cv_c_restrict" != no && break done ]) + AH_VERBATIM([restrict], +[/* Define to equivalent of C99 restrict keyword, or to nothing if this +is not supported. Do not define if restrict is supported directly. +Favor a definition that works in both C and C++. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict, even + though the corresponding Sun C compiler does. Perhaps some future + version of Sun C++ will work with _Restrict; if so, it'll probably + define __RESTRICT, just as Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +#endif]) case $ac_cv_c_restrict in restrict) ;; - no) AC_DEFINE(restrict,, - [Define to equivalent of C99 restrict keyword, or to nothing if this - is not supported. Do not define if restrict is supported directly.]) ;; - *) AC_DEFINE_UNQUOTED(restrict, $ac_cv_c_restrict) ;; + no) AC_DEFINE([restrict], []) ;; + *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; esac ])# AC_C_RESTRICT -- 1.5.3.2 -- View this message in context: http://www.nabble.com/AC_C_RESTRICT-and-C-C%2B%2B-tf4668063.html#a13349412 Sent from the Gnu - Autoconf - Bugs mailing list archive at Nabble.com.