Sorry guys, but here is my post again with some important information edited in.
I'm using %array_class(int, intArray) to be able to pass an array reference to my my cpp-code from the python interpreter. The cpp-function uses the reference to fill the array with values, but when I dereference the array from python odd indexes contain random data and even indexes contain what they are supposed to.
I've created a test case where the value of index 0 should contain value 0, index 1 should contain value 1, index 2 should contain value 2 and so on. What I get is:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import test >>> a = test.intArray(20) >>> test.getVector(a, 20) >>> a 0 >>> a 140211501511192 >>> a 2 >>> a 7914004857907398901 >>> a 4
I'm on a 64-bit box so I'm pretty sure there is some mix up of what's to be interpreted as 32-bit and what's to be interpreted as 64-bits, but I'm very confused as to where this problem is introduced and how to amend it. I'm using swig 1.3.40 and compiling with g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2.