Abi
Selects the calling convention a function is compiled with — the contract for how arguments, the return value, and the stack are arranged. Most code never needs it: Rux uses the right convention for the target automatically. Reach for #Abi at a foreign boundary that must follow a specific ABI regardless of the platform default.
Syntax
#Abi(.SysV)
func FastPath(a: int32, b: int32) -> int32 {
return a + b;
}
The argument is one of three ABI variants:
| Variant | Convention |
|---|---|
.C | Whatever the target's C ABI is — Win64 on Windows, System V elsewhere |
.SysV | System V AMD64 (Linux, the BSDs, macOS) |
.Win64 | Microsoft x64 |
Without #Abi, a function uses the platform's default convention. #Abi(.C) is the form to use when calling into or being called from C.
On extern and asm
#Abi is most useful on declarations that cross a language boundary — extern functions and asm func bodies — where the ABI must match exactly what the other side expects:
#Abi(.Win64)
asm func Add(a: int32, b: int32) -> int32 {
mov eax, ecx // Win64: first two integer args in ecx/edx
add eax, edx
ret
}
See Also
- Assembler Functions — where a fixed ABI matters most
externDeclarations — foreign functions that follow a C ABI- Attributes — the full attribute set
Link
Names the native library an extern function is imported from, and optionally the exported symbol to bind to. The operating system loader resolves the library by name at run time.
Warn
Emits a compiler warning at every call site of the annotated function. The function remains callable; the warning is informational.