c99_compat.h: Don't try to use 'restrict' in C++ code
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Sat, 10 Sep 2016 16:46:02 +0000 (09:46 -0700)
committerEric Engestrom <eric.engestrom@intel.com>
Wed, 16 Oct 2019 12:45:57 +0000 (13:45 +0100)
Fixes build failures on Solaris in C++ files using gcc:

../src/util/u_math.h:628:41: error: expected ‘,’ or ‘...’ before ‘dest’
  628 | util_memcpy_cpu_to_le32(void * restrict dest, const void * restrict src, size_t n)
      |                                         ^~~~
../src/util/u_math.h: In function ‘void* util_memcpy_cpu_to_le32(void*)’:
../src/util/u_math.h:641:18: error: ‘dest’ was not declared in this scope
  641 |    return memcpy(dest, src, n);
      |                  ^~~~
../src/util/u_math.h:641:24: error: ‘src’ was not declared in this scope
  641 |    return memcpy(dest, src, n);
      |                        ^~~
../src/util/u_math.h:641:29: error: ‘n’ was not declared in this scope; did you mean ‘yn’?
  641 |    return memcpy(dest, src, n);
      |                             ^
      |                             yn

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
include/c99_compat.h

index d704baf12b91f2831a757d745674c41e28828026..729b5b798688c1841625d0ff313a9b3efe03529b 100644 (file)
@@ -96,7 +96,7 @@
  * - http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
  */
 #ifndef restrict
-#  if (__STDC_VERSION__ >= 199901L)
+#  if (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
      /* C99 */
 #  elif defined(__GNUC__)
 #    define restrict __restrict__