Message 133591 - Python tracker (original) (raw)
I can reproduce this with 2.7 and 3.2 64-bit builds on Windows:
D:\Temp\cdll\x64\Release>C:\Python32\python.exe Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win 32 Type "help", "copyright", "credits" or "license" for more information.
from ctypes import * libcdll = CDLL('cdll') libcdll.foo(1, 2, 3, 4, 5, 6, 7) a: 1; b: 2; c: 3; d: 4; e: 5; f: 6; g: 7 0 class MyStruct(Structure): ... fields = [ ... ('a', c_int32), ... ('b', c_int32), ... ('c', c_int32), ... ('d', c_int32), ... ('e', c_int32), ... ('f', c_int32), ... ('g', c_int32), ... ] ... s1 = MyStruct(1, 2, 3, 4, 5, 6, 7) s2 = MyStruct(0, 9, 8, 7, 6, 5, 4) libcdll.bar(s2) s.a: 0; s.b: 9; s.c: 8; s.d: 7; s.e: 6; s.f: 5; s.g: 4 0 libcdll.errorPassingParameter(s1, s2, 42) s1.a: 1; s1.b: 2; s1.c: 3; s1.d: 4; s1.e: 5; s1.f: 6; s1.g: 7 s2.a: 28; s2.b: 0; s2.c: 851972; s2.d: 0; s2.e: 31545776; s2.f: 0; s2.g: 0 x: 39805032 0