Search code examples
cvisual-studiogccc89restrict-qualifier

What's a good way to check availability of __restrict keyword?


I am looking a set of #ifdef's to check availability of __restrict keyword for GCC and Visual Studio. I assume that it needs to check compiler version, but I don't know for which versions it was introduced. Anyone that can help me out?

UPDATE: This must (and only needs to) work when compiling as C89! So I cannot rely on __STDC_VERSION__ indicating C99, or C99 support.


Solution

  • How I fixed it:

    #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
    #   define SKP_restrict __restrict
    #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #   define SKP_restrict __restrict
    #else
    #   define SKP_restrict
    #endif