c_func

Definition: atom a = c_func(integer rid, sequence s)
Description: Call the C function with routine id rid. rid must be a valid routine id returned by define_c_func(). s is a sequence of argument values of length n, where n is the number of arguments required by the function. a will be the result returned by the C function.
Comments: If the C function does not take any arguments then s should be {}.
If you pass an argument value which contains a fractional part, where the C function expects a C integer type, the argument is rounded towards 0, for example 5.9 is passed as 5, -5.9 is passed as -5.
The C function could be part of a .dll or .so created via a format DLL/SO directive.
Example:
atom user32, hwnd, ps, hdc
integer BeginPaint
-- open user32.dll - it contains the BeginPaint C function
user32 = open_dll("user32.dll")
-- the C function BeginPaint takes a C int argument and
-- a C pointer, and returns a C int as a result:
BeginPaint = define_c_func(user32, "BeginPaint",
                           {C_INT, C_POINTER}, C_INT)
-- call BeginPaint, passing hwnd and ps as the arguments,
-- hdc is assigned the result:
hdc = c_func(BeginPaint, {hwnd, ps})
See Also: c_proc, define_c_func, open_dll, Calling C Functions