# define_cffi_proc

Definition: | include cffi.e integer id = define_cffi_proc(object lib, string cdef, integer machine=machine_bits()) (note: this is a text-based wrapper of define_c_proc)
Description: | parse a string containing a C void function definition and obtain a routine id.
pwa/p2js: | Not supported.
Comments: | Converts a textual C void function definition, such as one copied directly from MSDN, to the parameters expected by define_c_proc(), and returns the routine_id obtained by calling that function. In other words `define_cffi_proc("... HWND ...")` is equivalent to, and in fact maps to `define_c_proc(...{.. C_PTR ..}...)`, with most of the previously manual conversion automated for you. a proc is expected to begin with a "void" return type. 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 void function definition may contain comments, however they must be C-style, ie/eg `// comment` or `/* comment */`, not `-- comment`.
Example: |
    include cffi.e
    constant tSleep="""
    VOID WINAPI Sleep(
      _In_  DWORD dwMilliseconds
    );
    """
    constant xSleep = define_cffi_proc("kernel32.dll",tSleep)
    c_proc(xSleep,{500})
set_unicode() is needed before any auto "A/W" handling.
See Also: | define_c_proc, c_proc, set_unicode, machine_bits
Technicalia | define_c_proc is rather carefree regarding type: if something is a 4 byte dword (or an 8 byte qword), it does not care whether it is signed, a BOOL, an INT, a PTR, etc.