represents a foreign callback that can be called from external libraries.
ForeignCallback
represents a foreign callback that can be called from external libraries.
Details
- ForeignCallback is returned by functions such as CreateForeignCallback.
- Information for a ForeignFunction may include the following properties:
-
"Function" callback function "FunctionPointer" memory address - ForeignCallback is automatically unwrapped as a function pointer when passed as an argument to a ForeignFunction that expects a pointer.
Examples
open all close allBasic Examples (1)
Load a foreign function that takes a function pointer:
createArray = ForeignFunctionLoad["compilerDemoBase", "createArray", {"OpaqueRawPointer"} -> "RawPointer"::["CLong"]]Create a foreign callback function:
cbFun = CreateForeignCallback[EchoEvaluation[# ^ 2]&, {"CLong"} -> "CLong"]Call the foreign function and pass the foreign callback:
ptr = createArray[cbFun]RawMemoryImport[ptr, {"List", 10}]Scope (1)
Information (1)
cb = CreateForeignCallback[EchoEvaluation[# ^ 2]&, {"CLong"} -> "CLong"]Get Information about the callback:
Information[cb["Value"]]Tech Notes
Related Guides
History
Text
Wolfram Research (2023), ForeignCallback, Wolfram Language function, https://reference.wolfram.com/language/ref/ForeignCallback.html.
CMS
Wolfram Language. 2023. "ForeignCallback." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ForeignCallback.html.
APA
Wolfram Language. (2023). ForeignCallback. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ForeignCallback.html
BibTeX
@misc{reference.wolfram_2026_foreigncallback, author="Wolfram Research", title="{ForeignCallback}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/ForeignCallback.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_foreigncallback, organization={Wolfram Research}, title={ForeignCallback}, year={2023}, url={https://reference.wolfram.com/language/ref/ForeignCallback.html}, note=[Accessed: 12-June-2026]}