Call a foreign-language function: Difference between revisions
Call a foreign-language function (view source)
Revision as of 11:46, 17 November 2023
, 6 months ago→{{header|Wren}}: Oops!
m (→{{header|Wren}}: Capitalize Wren file name.) |
m (→{{header|Wren}}: Oops!) |
||
Line 2,839:
Although RC task solutions are usually written for execution by Wren CLI, the language's main purpose is for embedding and the embedding API is written in C. It is therefore a relative easy matter to call a C function from Wren after first embedding the latter in a suitable C program.
<syntaxhighlight lang="wren">/*
class C {
Line 2,917:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
|