Bug 51009: _X_RESTRICT_KYWD fix for g++ 4.6 & later on Solaris

g++ 4.6 & later on Solaris set the __STDC_VERSION__ define to indicate
C99 mode to expose C99/Unix03 functions in the system headers, even
though they don't recognize the C99 restrict keyword, as explained in
http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01308.html

Thus we avoid using the restrict keyword here if __cplusplus is also
defined, falling back to the __GNUC__ case using __restrict__ instead.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=51009

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Tested-by: Jonathan Perkin
This commit is contained in:
Alan Coopersmith 2012-08-26 14:36:50 -07:00
parent f1b8b4dd5e
commit c76d51423d

View file

@ -161,7 +161,8 @@ in this Software without prior written authorization from The Open Group.
/* requires xproto >= 7.0.21 */
#ifndef _X_RESTRICT_KYWD
# if defined(restrict) /* assume autoconf set it correctly */ || \
(defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */
(defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \
&& !defined(__cplusplus)) /* Workaround g++ issue on Solaris */
# define _X_RESTRICT_KYWD restrict
# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
# define _X_RESTRICT_KYWD __restrict__