Application binary interface 2026-11-05
An application binary interface specifies the conventions that separately compiled program components must share to cooperate at the binary level. It includes a calling convention, representations and layout of data, and platform conventions for object files. A common source-language declaration alone does not ensure that the generated machine instructions agree on where arguments and results reside.
For example, Microsoft's x64 calling convention passes the first two integer arguments in the processor registers
RCX and RDX, and returns a suitable scalar integer result in RAX.[ref]x64 Calling Convention by Microsoft. Parameter passing, integer row; Return values, scalar values fitting in 64 bits
A caller placing 7 and 5 in different processor registers from those expected by the called function can obtain the wrong result even if both sides describe an addition function. Matching the application binary interface allows a compiler and hand-written assembly language to cooperate; it does not require them to use the same internal implementation. Memory alignment 2026-11-05
Memory alignment restricts the memory addresses at which an object may begin. An alignment of bytes means that its starting byte address satisfies . For example, address satisfies eight-byte memory alignment, whereas address does not. Alignment is a constraint on location, rather than another name for an object's size.
In the C programming language, object types have alignment requirements;
_Alignof queries a type's requirement and _Alignas can request a supported stronger requirement. The actual values depend on the implementation. The C11 draft distinguishes fundamental from implementation-supported extended alignments and requires valid alignment values to be powers of two.[ref]An application binary interface makes such choices concrete. Under the ordinary AAPCS64 layout, a C structure containing a
char tag followed by a double value has the character at offset , seven unused padding bytes, and the double at offset . Its total size is bytes and its alignment is bytes. The application binary interface aligns an aggregate as strictly as its most strictly aligned member and rounds the aggregate size up to a multiple of that alignment; this also keeps each element properly aligned in an array of these structures.[ref]This example is an explicit platform convention, rather than a universal promise that every C
double needs eight-byte memory alignment. Likewise, a processor's ability to execute an unaligned load does not by itself relax the C programming language's object-access requirements. Keeping the language rule, the application binary interface layout, and the machine instruction separate explains why a byte buffer cannot automatically be treated as a properly located object of any chosen type.