I'm using python 2.6 on Linux/CentOs 6.x I'm getting ctypes to work, but getting stuck on the use of .argtypes. Can someone point out what I'm doing. This is my first use of ctypes and it looks like I'm getting different definitions in stackoverflow that may correspond to different version of python.
Here is my code. Without the restype/argtypes it works, but I cannot figure out how to define argtypes to match the data. mylibrary = ctypes.CDLL(LIBRARY_PATH) mdsconvert = mylibrary.RugVersionConverter mdsconvert.restype = ctypes.c_int mdsconvert.argtypes = [ charptr, #flat buffer of mds 3.0 data ctypes.c_buffer, #computed flat buffer of mds 2.0 data ctypes.c_buffer #version set to "1.00.4" in c++, never used ] def convertMds2to3(mds30buffer): mds20 = ctypes.create_string_buffer('\000'*3000) t = ctypes.create_string_buffer('\000'*30) success = mdsconvert(mds30buffer, ctypes.byref(mds20), ctypes.byref(t) ) print 'convert %s to %s success=%s version=%s' % (len(mds30buffer), len(mds20.value), success, t.value) return mds20.value ------------------------------- C++ code looks like this ------------------------------------------------------- extern "C" int RugVersionConverter( char * sInputRecord, char * MDS2_Rec, char * Version ); where sInputRecord is input and MDS2_Rec and Version are output. -- https://mail.python.org/mailman/listinfo/python-list