On Sat, Mar 14, 2009 at 8:52 PM, Sturla Molden <stu...@molden.no> wrote:
> > > 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: > Can't help but be ugly when dealing with all the compilers out there. > > #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 I think MSVC uses _inline > > #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 > What does this last bit do? We implicitly assume that ieee floating point is available. > > #ifdef DOUBLE > typedef double Treal > #else > typedef float Treal > #endif > typedef Treal *RESTRICT Vreal /* V as in "vector" */ > > I'm not sure about the names. I would prefer to keep the declarations along the lines of double * NPY_RESTRICT ptmp; As it is easier to read and understand without going to the macro definition. Note that David has a quite involved check for the inline keyword implementation and I expect he would want to do the same for the restrict keyword. I think using lots of #if defined(xxx) might be easier but I leave that stuff alone. It's David's headache. Chuck
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion