From 94b77e5db520d7db7ac19762896907ba6c8a46d6 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 31 Mar 2004 11:45:45 +0000 Subject: [PATCH] replace explicit static_cast(v) with old style (T)v, just in case git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5812 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/unnamed.swg | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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