]> www.ginac.de Git - cln.git/blobdiff - include/cln/number.h
64-bit mingw port: Define intV in terms of intP.
[cln.git] / include / cln / number.h
index da0b2fd3e6c7a6e0f286f1d7eae3f4cd3b5068b5..8abb22bfd6b600e883373c2abf233b6790c32ce3 100644 (file)
 
 // Constructors and assignment operators from C numeric types.
 
+#ifdef _MSC_VER
+// Workaround to force MSVC to tag the symbol with the cln:: namespace
+// When declaring inside an inlined function the symbol is placed in the 
+// global namespace!
+namespace cln {
+extern cl_private_thing cl_I_constructor_from_L (sint32 wert);
+extern cl_private_thing cl_I_constructor_from_UL (uint32 wert);
+extern cl_private_thing cl_I_constructor_from_Q (sint64 wert);
+extern cl_private_thing cl_I_constructor_from_UQ (uint64 wert);
+}
+#endif
+
 #define CL_DEFINE_INT_CONSTRUCTOR(_class_,_type_)  \
 inline _class_::_class_ (const _type_ wert)                            \
 {                                                                      \
@@ -146,34 +158,32 @@ namespace cln {
 // Constructors and assignment operators from C numeric types.
 
 // from `float':
-union ffloatjanus;
-extern cl_private_thing cl_float_to_FF_pointer (const union ffloatjanus& val);
+extern cl_private_thing cl_float_to_FF_pointer (const float val);
 
 #define CL_DEFINE_FLOAT_CONSTRUCTOR(_class_)                           \
 inline _class_ :: _class_ (const float x)                              \
 {                                                                      \
-       pointer = cl_float_to_FF_pointer(*(const union ffloatjanus *)&x); \
+       pointer = cl_float_to_FF_pointer(x);                            \
 }                                                                      \
 inline _class_& _class_::operator= (const float x)                     \
 {                                                                      \
        cl_dec_refcount(*this);                                         \
-       pointer = cl_float_to_FF_pointer(*(const union ffloatjanus *)&x); \
+       pointer = cl_float_to_FF_pointer(x);                            \
        return *this;                                                   \
 }
 
 // from `double':
-union dfloatjanus;
-extern struct cl_heap_dfloat * cl_double_to_DF_pointer (const union dfloatjanus& val);
+extern struct cl_heap_dfloat * cl_double_to_DF_pointer (const double val);
 
 #define CL_DEFINE_DOUBLE_CONSTRUCTOR(_class_)                          \
 inline _class_::_class_ (const double x)                               \
 {                                                                      \
-       pointer = cl_double_to_DF_pointer(*(const union dfloatjanus *)&x); \
+       pointer = cl_double_to_DF_pointer(x);                           \
 }                                                                      \
 inline _class_& _class_::operator= (const double x)                    \
 {                                                                      \
        cl_dec_refcount(*this);                                         \
-       pointer = cl_double_to_DF_pointer(*(const union dfloatjanus *)&x); \
+       pointer = cl_double_to_DF_pointer(x);                           \
        return *this;                                                   \
 }
 
@@ -247,7 +257,8 @@ template<class type>
 inline const type& the(const cl_number& x)
 {
        // check that sizeof(type)==sizeof(cl_number)
-       typedef int assertion1 [1 - 2 * (sizeof(type) != sizeof(cl_number))];
+       static_assert(sizeof(type)==sizeof(cl_number),
+                     "sizeof(type)!=sizeof(cl_number)");
        return *(const type *) &x;
 }
 // Conversions to subtypes without checking, macro version: