Hello,

 Support for long type was recently added to exchange-traits.h, see
http://www.mail-archive.com/[email protected]/msg00944.html
but this was done using __WORDSIZE which is only defined by g++ and so
didn't help with Windows build.

 Below is an improved patch which does the same thing portably, it's based
on the same idea as Michael Evdokimov's proposal in the above thread but
not strictly identical to it.

 Please consider applying it, thanks,
VZ

>From 6d8fe5112ade1dc40a1f2fa31d53d4efae0f2557 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <[email protected]>
Date: Sat, 19 May 2012 00:20:07 +0200
Subject: [PATCH] Support parameters of type "long" correctly under all 
platforms.

Recent change added proper support for "long" parameters but relied on
__WORDSIZE being defined which isn't the case under e.g. Windows with MSVC.

Use template partial specialization to correctly select the tag for "long"
under both 32 and 64 bit architectures without using __WORDSIZE now.

Signed-off-by: Vadim Zeitlin <[email protected]>
---
 src/core/exchange-traits.h |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/core/exchange-traits.h b/src/core/exchange-traits.h
index 81ecec4..d184d5f 100644
--- a/src/core/exchange-traits.h
+++ b/src/core/exchange-traits.h
@@ -83,21 +83,17 @@ struct exchange_traits<unsigned long long>
     enum { x_type = x_unsigned_long_long };
 };

-#if defined (__LP64__) || ( __WORDSIZE == 64 )
-template <>
-struct exchange_traits<long int>
-{
-    typedef basic_type_tag type_family;
-    enum { x_type = x_long_long };
-};
-#elif ( __WORDSIZE == 32 )
+// long must be mapped either to x_integer or x_long_long:
+template<int long_size> struct long_traits_helper;
+template<> struct long_traits_helper<4> { enum { x_type = x_integer }; };
+template<> struct long_traits_helper<8> { enum { x_type = x_long_long }; };
+
 template <>
 struct exchange_traits<long int>
 {
     typedef basic_type_tag type_family;
-    enum { x_type = x_integer };
+    enum { x_type = long_traits_helper<sizeof(long int)>::x_type };
 };
-#endif // #if defined (__LP64__) || ( __WORDSIZE == 64 )

 template <>
 struct exchange_traits<double>
--
1.7.2.5

Attachment: pgp3wrTyjPQAO.pgp
Description: PGP signature

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to