diff --git a/wrap/matlab.h b/wrap/matlab.h index 253ae74e79..0547ceb51a 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -160,13 +160,15 @@ mxArray* wrap(const bool& value) { return result; } -// specialization to size_t +// specialization to size_t but skip Win64 size check & CUDACC check +#if (!defined(_WIN64) && !defined(__LP64__)) || defined(__CUDACC__) template<> mxArray* wrap(const size_t& value) { mxArray *result = scalar(mxUINT32OR64_CLASS); *(size_t*)mxGetData(result) = value; return result; } +#endif // specialization to int template<> @@ -346,12 +348,16 @@ uint64_t unwrap(const mxArray* array) { return myGetScalar(array); } -// specialization to size_t +// specialization to size_t; omit it on Win64 because size_t is uint64_t there +// and would duplicate unwrap. The __CUDACC__ case intentionally +// bypasses the Win64 guard when compiling with CUDA. +#if (!defined(_WIN64) && !defined(__LP64__)) || defined(__CUDACC__) template<> size_t unwrap(const mxArray* array) { checkScalar(array, "unwrap"); return myGetScalar(array); } +#endif // specialization to double template<>