Change the following to no longer have the compiler produce C4244 and C4267 warnings
File: Objects.hxx
long hashValue() const
{
return PyObject_Hash( p );
}
should be
long hashValue() const
{
return (long)PyObject_Hash( p );
}
void extend( const Object &ob )
{
setSlice( size(), size(), ob );
}
should be
void extend( const Object &ob )
{
setSlice( (int)size(), (int)size(), ob );
}
int length() const
{
return PyMapping_Length( ptr() );
}
should be
int length() const
{
return PyMapping_Length( ptr() );
}
Forgot to add the typecast to the last method, should be
int length() const
{
return (int)PyMapping_Length( ptr() );
}
I think the right fix is to return Py_ssize_t for the length calls, which is signed not size_t that is unsigned.
At least on linux hash() is a long and should not need casting.
I have committed changes from the work on linux to change to use Py_ssize_t.
I will update with feedback from vc2015 testing in a bit.
r353 should fix the compiler warnings and fix the bugs that they point to.
Namely lose of precision, turning 64 bit values into 32 bit values.
tested on python 2.7 and python 3.5 32 and 64 bit windows, mac and linux
You may need to fix calling code to use Py_ssize_t and Py_hash_t to avoid truncation.