ctypes pointer

mclaugb mclaugb at nospm.yahoo.com
Tue Jun 19 18:50:58 CEST 2007


Yes, i double defined one of the terms when copying it.
This now works by value and by reference.
Thanks alot,
Bryan


"Thomas Heller" <theller at ctypes.org> wrote in message 
news:mailman.9235.1182268634.32031.python-list at python.org...
> mclaugb schrieb:
>> I have a simple function
>>
>> void adder(double a, double b, double *c){
>> *c = a+b;
>> }
>>
>> i have created a shared dll -- "small_dll4.dll" of it using visual 
>> studio.
>>
>> now i wish to call it from python.
>> to do so, i have done the following:
>>
>> libx = cdll("small_dll4.dll", RTLD_GLOBAL)
>> libx.adder.argtypes = [c_double, c_double, POINTER(c_double)]
>> libx.adder.restype = None
>> size=c_double()
>> zz=libd.adder(3.342, 4, byref(size))
>>
>> and the result is an access violation!
>>
>>   File "<console>", line 0, in __main__
>> WindowsError: exception: access violation reading 0x7EF9DB23
>>
>> I cant figure out what is causing this.
>
> That should work (and works for me, of course).
> Do you have a typo in the above code?  libd instead of libx?
>
> Thomas
> 





More information about the Python-list mailing list