4. Application Binary Interface

4.1. Name Mangling

4.1.1. Functions

Function mangled name is composed of the following sequence:

  1. A literal _P
  2. Function name encoding:
    1. Number of characters in the function’s base name
    2. The function’s base name, verbatim
  3. Function’s return type
    1. A literal R
    2. mangled name of return type
    3. A literal E
  4. Function’s parameters
    1. A literal P
    2. All positional parameters’ mangled type name in sequence.
    3. A literal E

4.1.2. Types Modifiers

  • Mutable types have a prefix m
  • Reference types begin with r Scalar (built-in) types

Built-in types mangle according to the following table:

Type Mangled name
Void v
Bool b
Signed integer s followed by number of bytes (S8 is s1)
Unsigned integer u followed by number of bytes
Character c followed by number of bytes Pointers

Pointer type is mangled as p followed by the pointed to type mangling Arrays

  1. A literal A
  2. Number signifying the array’s dimensions
  3. Mangled name of element type Structs

  1. A literal S.
  2. If the struct is namespace or otherwise scoped, the scope’s representation follows.
  3. Next comes the total length, in decimal, of the struct’s data.
  4. The struct’s name.
  5. 8 characters encoding the hash of the struct’s content. Struct Hash Encoding

The struct’s hash value is calculated over it’s name and members according to the following formula:


If a struct indirectly points back to itself (e.g. contains a pointer to itself), the inner struct reports a fixed hash value of 0x2bcdadbd0483cb7c.

The hash is calculated in 64 bits.

The lower 48 bits of the hash are taken, and then encoded with Base64 with + replaced with _ and / replaced with @. On platforms where @ cannot be used, another symbol MUST be used for that specific platform. On platforms where no second character is available, the ABI SHOULD use Base63 (47.8 bits). It MAY use Base32 (40 bits). It MAY also use plain hexadecimal representation with upper case letters (32 bits).