1 The `dlsym()` method accepts a full C function declaration in place of a bare 2 symbol name. The result has the declared function type, so `wrap()` can call 3 it. A declaration without a name still raises an exception. 4 5 -- Testcase -- 6 {% 7 import * as ffi from 'ffi'; 8 9 let abs_sym = ffi.C.dlsym('int abs(int)'); 10 print("abs: ", ffi.C.wrap(abs_sym)(-7), "\n"); 11 12 let getenv = ffi.C.dlsym('char *getenv(char *)'); 13 print("getenv: ", ffi.string(ffi.C.wrap(getenv)('FFI_DLSYM_DECL')), "\n"); 14 15 try { 16 ffi.C.dlsym('int (*)(int)'); 17 } 18 catch (e) { 19 print("unnamed: ", e.message, "\n"); 20 } 21 %} 22 -- End -- 23 24 -- Vars -- 25 FFI_DLSYM_DECL=declared 26 -- End -- 27 28 -- Expect stdout -- 29 abs: 7 30 getenv: declared 31 unnamed: declaration does not define a named symbol 32 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt