[C++-sig] Can't convert to unsigned int

Mark Russell mrussell8081 at pacbell.net
Wed Dec 11 02:46:30 CET 2002

I am wrapping a library that makes extensive use of flags (in varying
guises) that are unsigned longs.  I have put together a simplified example
below--when I try to use this module I get an overflow error.  Is there a
way to make this type of conversion? Thanks in advance.  --Mark

struct bigint {
	unsigned long flag;

#include <boost/python.hpp>
using namespace boost::python;

		.def_readwrite("flag", &bigint::flag);

C:\developer\Python D3D8\dword>python
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ul import *
>>> b = bigint()
>>> b.flag = 0x80000000l
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: long int too large to convert to int

More information about the Cplusplus-sig mailing list