Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Errors when passing arrays to C function via ctypes

Reply
Thread Tools

Errors when passing arrays to C function via ctypes

 
 
d80013 d80013 is offline
Junior Member
Join Date: Nov 2008
Posts: 1
 
      11-25-2008
Hello all,

I am trying to integrate a C libary (well, a C API to a C++ library) and I am getting an error when passing arrays to the C function.

I have a C function defined as:
C_API const char* myfunc(const char* ccy, const int days[], const int n_days,const double dfs[], const int n_dfs, const int anchor_date, const char* dycnt);

and I define the arrays days[] and dfs[] as:

d = c_int * 10
r = c_double * 10
days = d(1,2,3,4,5,6,7,8,9,10)
dfs = r(1.0, 2.0, 3.0,4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)

and the error I get is :
WindowsError: exception code 0xe06d7363

The function I should mention works fine from C.

Also, I have another function defined as:

C_API const char* myfunc2(const char* type, int n_factors, const double** data, const int n_rows, const int n_cols);

and if I pass one of the single dimension arrays from above for the data variable, I get the following error:

WindowsError: exception: access violation reading 0x00000001

Any help would be greatly appreciated.

Thanks,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to free memory allocated by a function call via ctypes Tzury Bar Yochay Python 1 05-30-2009 08:49 PM
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
WindowsXP/ CTypes - How to convert ctypes array to a string? dudeja.rajat@gmail.com Python 0 08-19-2008 10:20 AM
Sending arrays of a structure as an argument via ctypes Knut Saua Mathiesen Python 1 06-23-2008 01:46 PM
RE: [ctypes-users] [Ann] ctypes 0.9.0 released Henk Punt Python 0 07-23-2004 10:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57