diff --git a/Lib/unnamed.swg b/Lib/unnamed.swg index 71dfd9d40..bc5adb0ee 100644 --- a/Lib/unnamed.swg +++ b/Lib/unnamed.swg @@ -20,12 +20,17 @@ // Activate the following macro for compilers that do not support // unnamed template parameters, but where memcpy works. // -//#define SWIG_UNNAMED_USE_MEMCPY +#define SWIG_UNNAMED_USE_MEMCPY +// // #ifdef SWIG_UNNAMED_USE_MEMCPY -// dangerous assigment, but for enums it should work. +// "dangerous" assigment, but for enums it should work. +// it is dangerous because you could get a bad value, +// but it is safer than "*(T*)(void*)&x = t;", which +// could produce a seg. fault. #define swig_assign_unnamed(eval, val) memcpy(&(eval),&(val), sizeof(eval)) #else +// much much safer choice :) #define swig_assign_unnamed(eval, val) printf("unnamed member assigment not supported\n") #endif #else @@ -33,7 +38,9 @@ template inline void swig_assign_unnamed(T& eval, const V& val) { - eval = static_cast(val); + // it 'should' be: eval = static_cast(val); + // but just in case we found a very very old compiler + eval = (T)val; } #endif #else