Anonymous user
Call a function in a shared library: Difference between revisions
Call a function in a shared library (view source)
Revision as of 00:18, 11 January 2021
, 3 years ago→{{header|Crystal}}: add crystal implementation
m (→{{header|REXX}}: elided a blank line.) |
(→{{header|Crystal}}: add crystal implementation) |
||
Line 274:
:pointer)
#.(SB-SYS:INT-SAP #X00650FD0)</lang>
=={{header|Crystal}}==
<lang ruby>libm = LibC.dlopen("libm.so", LibC::RTLD_LAZY)
libm.value.not_nil!
sqrtptr = LibC.dlsym(libm, "sqrt")
sqrtptr.value.not_nil!
sqrtproc = Proc(Float64, Float64).new sqrtptr, Pointer(Void).null
puts "the sqrt of 4 is #{sqrtproc.call(4.0)}"
LibC.dlclose(libm)</lang>
=={{header|D}}==
|