CodeBlanks Logo Icon CodeBlanks

Itanium ABI

Learn the Itanium ABI and its common usage.

Itanium ABI

The Itanium C++ ABI is the mangling and layout standard shared by GCC and Clang. It was first designed for the Itanium architecture but became the default ABI on all architectures on Linux and macOS.

The Itanium mangling rules are documented; this lets different compilers produce the same symbol names. Example: void foo() → _Z3foov. MSVC uses its own ABI; that is why a GCC-compiled library cannot link directly to an MSVC program. C linkage (extern "C") is the common bridge.

Type codes

The Itanium ABI type codes are single letters: v = void, i = int, d = double, b = bool, c = char, l = long. Names are written with a length prefix: 5print = print.

So the signature void print(int) becomes _Z5printi: _Z prefix, 5print name, i int parameter. As long as the signature does not change, the symbol stays the same; this is the basis of ABI stability.

Practice Write a namespaced function

Write namespace ns { int compute(int x) { return x * 2; } }. In main write std::cout << ns::compute(5);.

Starter code

main.cpp
#include <iostream>

// Define the compute function in namespace ns here

int main() {
    // Call compute and print it
    return 0;
}

Sample solution

main.cpp
#include <iostream>

namespace ns {
    int compute(int x) {
        return x * 2;
    }
}

int main() {
    std::cout << ns::compute(5);
    return 0;
}

Expected output

10

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Match each symbol to its signature

Term Meaning
_Z3foov foo() symbol
_Z3addii add(int, int) symbol
_ZN2ns3barEv ns::bar() symbol
_Z3bazv baz() symbol

2 Complete the mangled name

Question
_Z3foo____  // void foo()
Answer
_Z3foov  // void foo()

Explanation: The v type code means void.

3 What does the 'i' type code represent in the Itanium ABI?

main.cpp
_Z3addii  // add(int, int)
  • int Correct answer
  • double
  • bool
  • void

Explanation: The right answer is: int. In Itanium, i = int, d = double, v = void, b = bool.

All lessons in Expert