Calling-convention descriptor objects used in function import and export descriptors. The module exports cdecl and stdcall. Each descriptor is one object whose public field CALL supplies the calling-convention text when called.
Descriptor objects
cdecl and stdcall are callable Dict descriptors whose public CALL Block returns target-specific calling-convention Text.
Fields
CALL: a Block that supplies the convention Text when the descriptor is called.- The returned text is chosen using
storageSizeofNatx, not the operating-system name.
cdecl
cdecl
(-- text) Produces the C calling-convention text for the current target.- On a target with 8-byte
Natxstorage, leaves known Text"". On a target with anotherNatxsize, leaves"ccc". - Put
cdeclin theconventionfield of the options descriptor passed toimportFunctionorexportFunction. The descriptor call supplies the field's Text value.
stdcall
stdcall
(-- text) Produces the standard-call calling-convention text for the current target.- On a target with 8-byte
Natxstorage, leaves known Text"". On a target with anotherNatxsize, leaves"x86_stdcallcc". - Put
stdcallin theconventionfield of the options descriptor passed toimportFunctionorexportFunction.
Descriptor use
- The same options descriptor is also accepted by
codeRef; the convention text becomes part of the resultingCodeschema.
Known issue: The convention option is accepted and is part of the Code schema, but it is not emitted in generated LLVM declarations, definitions, or calls. With -32bits, stdcall functions are declared, defined, and called without x86_stdcallcc.
Examples
One descriptor in a callable declaration
"String" use
"control" use
"conventions" use
addOne: {value: Int32;} Int32 {convention: cdecl;} codeRef;
[1 +] !addOne
{} Int32 {} [
("result=" 41 addOne LF) printList
0
] "main" exportFunction
Expected Output
result=42
See also
importFunction(inputsSchema output options name --): Declares or imports a named function with the supplied signature and binds it in the current scope.exportFunction(inputsSchema output options callable name --): Exports a named function built from one Block and one signature.