define_cffi_func
| Definition: |
include cffi.e
integer rid = define_cffi_func(object lib, string cdef, integer machine=machine_bits()) (note: this is a text-based wrapper of define_c_func) |
| Description: | parse a string containing a C function definition and obtain a routine_id. |
| pwa/p2js: | Not supported. |
| Comments: |
Converts a textual C function definition, such as one copied directly from MSDN, to the parameters expected by define_c_func(),
and returns the routine_id obtained by calling that function. In other words
define_cffi_func("... HWND ...") is equivalent to, and in fact maps to
define_c_func(...{.. C_PTR ..}...), with most of the previously manual conversion automated for you.lib can be a string or the previous result of open_dll. The machine parameter can be set to 32 or 64, for testing purposes. The function definition may contain comments, however they must be C-style, ie/eg // comment or /* comment */,
not -- comment.
|
| Example: |
include cffi.e
constant tMB="""
int WINAPI MessageBox(
_In_opt_ HWND hWnd,
_In_opt_ LPCTSTR lpText,
_In_opt_ LPCTSTR lpCaption,
_In_ UINT uType
);
"""
set_unicode(0)
constant xMessageBox = define_cffi_func("user32.dll",tMB)
?c_func(xMessageBox,{0,"text","caption",0})
set_unicode() is needed before any auto "A/W" handling. |
| See Also: | define_c_func, allocate_struct, set_struct_field, get_struct_field, get_field_details, set_unicode, machine_bits |