From 5fe01237ea325dcdfe2190ad72c5d1d15094b5a7 Mon Sep 17 00:00:00 2001 From: thatdudegrantt Date: Mon, 18 May 2026 18:44:10 -0400 Subject: [PATCH] fix: guard size_t template specializations for Win64 On 64-bit Windows, size_t and uint64_t are the same underlying type, causing duplicate explicit template specialization errors when building the MATLAB wrapper. Guard both wrap and unwrap with #if !defined(_WIN64) || defined(__CUDACC__). this is because gtsam/wrap inherits from the wrap repository. Successfully locally tested the change in gtsam/wrap/matlab.h, and then migrating to truly make the change. I will be more careful about this in the future. --- matlab.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/matlab.h b/matlab.h index 5c7cf7a..61c786c 100644 --- a/matlab.h +++ b/matlab.h @@ -159,13 +159,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(__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<> @@ -345,12 +347,14 @@ uint64_t unwrap(const mxArray* array) { return myGetScalar(array); } -// specialization to size_t +// specialization to size_t but skip Win64 size check (size_t == uint64_t) & CUDACC check +#if !defined(_WIN64) || defined(__CUDACC__) template<> size_t unwrap(const mxArray* array) { checkScalar(array, "unwrap"); return myGetScalar(array); } +#endif // specialization to double template<>