Fortran 77 dll importieren + function aufrufen

Python in C/C++ embedden, C-Module, ctypes, Cython, SWIG, SIP etc sind hier richtig.
Antworten
BlackJack

@liddokun88: Arraytypen werden bei `ctypes` mit dem ``*``-Operator erzeugt.

Code: Alles auswählen

In [1]: import ctypes as ct

In [2]: ct.c_double * 8
Out[2]: <class '__main__.c_double_Array_8'>
liddokun88
User
Beiträge: 18
Registriert: Montag 5. März 2012, 16:11

Ich stehe heute auf dem Schlauch, wie soll das nun aussehen?

Code: Alles auswählen

from ctypes import *
c_double_p = POINTER(c_double)    
test = windll.LoadLibrary("test.dll");

# call the functions in the dll
def A(B,C):        # wobei C ein double array mit 8 argumenten ist
     A = test.A_BC     #select function in dll
     A.argtypes = [c_double_p,ctypes.c_double * 8] # input to double
     A.restype = c_double_p       

     B = c_double(B)

#   return value to console
    return A(byref(B), byref(class '__main__.c_double_Array_8'))
 
meinst du das so in der Richtung?
deets

Das ist doch noch nicht mal gueltiges Python.

Es steht in der ctypes-Doku wie man Array-Typen anlegt, und damit arbeitet um konkrete Arrays und Referenzen darauf zu erzeugen.

http://python.net/crew/theller/ctypes/t ... tml#arrays
Antworten