Call a foreign-language function: Difference between revisions
Content added Content deleted
(→{{header|CMake}}: Warn about deprecation. Add instruction to run `cmake .`.) |
|||
Line 888: | Line 888: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
Julia has a built-in keyword <code>ccall</code> to call external C-like functions. For example: |
Julia has a built-in keyword <code>ccall</code> to call external C-like functions. For example: |
||
<lang julia> |
<lang julia>p = ccall(:strdup, Ptr{Cuchar}, (Ptr{Cuchar},), "Hello world") |
||
@show unsafe_string(p) # "Hello world" |
|||
Ptr{Uint8} @0x000000011731bde0 |
|||
⚫ | |||
</lang> |
|||
julia> bytestring(p) # convert pointer back to a native Julia string |
|||
"Hello world" |
|||
⚫ | |||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |