Fix UseUintMax definition used by wxAny for VC6.

The old code tried to work around the lack of unsigned __int64 to double
conversion in VC6 by casting from UseUintMax to wxAnyBaseIntType but this was
wrong as this value was -1 when cast to wxAnyBaseIntType (__int64) and so
UseUintMaxF was defined as -1.0.

Use a slightly uglier but simpler work around now: just define the constants
as macros instead of (typed) variables and let the compiler deal with literal
values on its own (which it does correctly).

This fixes the unit test failure: conversion from double to unsigned always
failed when using VC6.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62471 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-10-22 11:18:02 +00:00
parent 17e48bcebf
commit 982d7f9317

View File

@@ -112,27 +112,23 @@ wxAnyValueType::wxAnyValueType()
//
// Define integer minimum and maximum as helpers
#ifdef wxLongLong_t
const wxAnyBaseIntType UseIntMin = wxINT64_MIN;
const wxAnyBaseUintType UseIntMax = wxINT64_MAX;
const wxAnyBaseUintType UseUintMax = wxUINT64_MAX;
#define UseIntMin (wxINT64_MIN)
#define UseIntMax (wxINT64_MAX)
#define UseUintMax (wxUINT64_MAX)
#else
const wxAnyBaseIntType UseIntMin = LONG_MIN;
const wxAnyBaseUintType UseUintMax = ULONG_MAX;
const wxAnyBaseUintType UseIntMax = LONG_MAX;
#define UseIntMin (LONG_MIN)
#define UseIntMax (LONG_MAX)
#define UseUintMax (ULONG_MAX)
#endif
namespace
{
const double UseIntMinF = static_cast<double>(UseIntMin);
#ifndef __VISUALC6__
const double UseIntMaxF = static_cast<double>(UseIntMax);
const double UseUintMaxF = static_cast<double>(UseUintMax);
#else
// VC6 doesn't implement conversion from unsigned __int64 to double
const wxAnyBaseIntType UseIntMax0 = static_cast<wxAnyBaseIntType>(UseIntMax);
const wxAnyBaseIntType UseUintMax0 = static_cast<wxAnyBaseIntType>(UseUintMax);
const double UseIntMaxF = static_cast<double>(UseIntMax0);
const double UseUintMaxF = static_cast<double>(UseUintMax0);
#endif
} // anonymous namespace
bool wxAnyValueTypeImplInt::ConvertValue(const wxAnyValueBuffer& src,
wxAnyValueType* dstType,