> Ok, but most GNU compilers has a __restrict__ extension for C89 and C++
> that we could use. And MSVC has a compiler pragma in VS2003 and a
> __restrict extension in VS2005 later versions.  So we could define a mscro
> RESTRICT to be restrict in ISO C99, __restrict__ in GCC 3 and 4,
> __restrict in recent versions of MSVC, and nothing elsewhere.


I know it's ugly, but something like this:

#define RESTRICT
#define INLINE
/*use GNU extension if possible*/
#ifdef __GNUC__
    #if (__GNUC__ >= 3)
        #undef RESTRICT
        #undef INLINE
        #define RESTRICT __restrict__
        #define INLINE __inline__
    #endif
#endif
/* use MSVC extensions if possible */
#ifdef MSVC
    #if (MSVC_VER >= 1400)
        #define RESTRICT __restrict
        #define INLINE inline
    #endif
#endif
#ifdef __cplusplus
extern "C" {
    #undef INLINE
    #define INLINE inline
#else
    /* use C99 if possible */
    #if (__STDC_VERSION__ >= 199901L)
        #undef RESTRICT
        #undef INLINE
        #define RESTRICT restrict
        #define INLINE inline
    #endif
#endif

#ifdef DOUBLE
    typedef double Treal
#else
    typedef float Treal
#endif
typedef Treal *RESTRICT Vreal /* V as in "vector" */


S.M.

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to