[Mesa-dev] [PATCH 02/13] isl: Add an ISL_RESTRICT #define for use in isl.h

Emil Velikov emil.l.velikov at gmail.com
Tue Apr 19 20:32:29 UTC 2016


On 16 April 2016 at 20:45, Jason Ekstrand <jason at jlekstrand.net> wrote:
> C++ doesn't define the "restrict" keyword so g++ barfs when it sees isl.h.
> Having our own define lets us define it to be a no-op for C++.
> ---
>  src/intel/isl/isl.h | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
> index 8f796b0..33d43d7 100644
> --- a/src/intel/isl/isl.h
> +++ b/src/intel/isl/isl.h
> @@ -47,6 +47,16 @@
>  extern "C" {
>  #endif
>
> +/* The restrict keyword is simply a hint to the optimizer and doesn't affect
> + * the caller of a function in any way.  We want it in the header for the sake
> + * of documentation but we can safely remove it to make C++ happy.
> + */
> +#ifdef __cplusplus
> +#define ISL_RESTRICT
> +#else
> +#define ISL_RESTRICT restrict
> +#endif
> +
Isn't the magic in include/c99_compat.h helping out ? Which version of
GCC are you using, do you have any extra C*FLAGS ? Asking because I
don't see this on my setup.

Mildly related:
Fwiw I do recall that MSVC barfs at us if the keyword is present in
the declaration but on the definition and vice-versa. IIRC the
Sun/Oracle compiler used to have similar requirement, if we are to get
that one working again.

Emil


More information about the mesa-dev mailing list