This repository has been archived by the owner on Jun 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Note: External Functions
alexrp edited this page Feb 28, 2013
·
2 revisions
External functions are declared like so:
pub fn ext "cdecl" my_public_fn() -> unit;
priv fn ext "cdecl" my_private_fn() -> unit;
pub fn ext "stdcall" my_stdcall_fn() -> unit;
pub fn ext "cdecl" my_cdecl_flect_fn() -> int {
42;
}
priv fn ext "flect" my_flect_fn -> unit {
}
There are a few things worth noting here:
- Visibility of an
ext
function does not have any effect on its name mangling or calling convention. - The
flect
calling convention is equivalent to not specifying any explicit calling convention withext
. - Specifying an unknown calling convention for a function is a semantic error.
- Specifying an unsupported calling convention for the current target shall only be diagnosed if the function is actually called or used somehow.
Function pointer types are enhanced with an ext
attribute:
let fptr : fn ext "cdecl"() -> unit = &my_public_fn;
A function pointer type with ext "flect"
implicitly converts to the equivalent type without an explicit calling convention.
- Home
- Introduction
- Motivation
- Features
- Tutorial
- Library
- FAQ
- General
- Interoperability
- Syntax
- Type System
- Macros and CTE
- Specification
- Introduction
- Lexical
- Common Grammar Elements
- Modules and Bundles
- Type System
- Declarations
- Expressions
- Macros
- Compile-Time Evaluation
- Memory Management
- Application Binary Interface
- Foreign Function Interface
- Unit Testing
- Documentation Comments
- Style
- Indentation
- Braces
- Spacing
- Naming