[ctypes-users] Calling a function with a custom datatype argument
Brought to you by:
theller
|
From: Rosalyn H. <r.s...@re...> - 2010-01-15 16:03:51
|
Hi, I'm new to using ctypes and while things were going really well, I've now hit a problem and have so far been unable to find the information I require. I've looked through the ctypes tutorial and reference manual, as well as google. I'm hoping someone might be able to help me out. I'm using ctypes to interface to the C library UDUNITS2. I wish to call the function: ut_error_message_handler ut_set_error_message_handler(ut_error_message_handler handler) from python where the C definition of the ut_error_message_handler datatype is as follows: typedef int (*ut_error_message_handler)(const char* fmt, va_list args); [In case it helps clarify things; handler is the name of one of the following functions; Function: int ut_write_to_stderr (const char* fmt, va_list args) Function: int ut_ignore (const char* fmt, va_list args) ] How do I create the ut_error_message_handler datatype in python and thus pass a correctly typed argument to the function? Thanks in advance, Rosalyn. -- ------------------------------------------------------------------------ Rosalyn Hatcher NCAS Computational Modelling Services Dept. of Meteorology, University of Reading, Earley Gate, Reading. RG6 6BB Email: r.s...@re... Tel: +44 (0) 118 378 6016 |