__ALIGNOF__(3)
π NAME π
okay bestie, this is the glow-up for __alignof__ from the Library Functions Manual β¨ itβs a GNU extension for the alignment of an object. periodt.
πΈ SYNOPSIS πΈ
int
__alignof__(void x);
π¦ DESCRIPTION π¦
so the __alignof__() operator returns the alignment of its operand π
the operand can be a type or an expression. if the operand is an lvalue, the return value represents the required alignment of the underlying type, not the actual alignment of the specified lvalue. no cap.
the returned value is specific to the architecture and the ABI π«Ά if the architecture does not impose strict alignment requirements, __alignof__() returns the minimum required alignment. and if __aligned(3) is used to increase the alignment, __alignof__() returns the specified alignment β¨
π EXAMPLES π
the syntax is comparable to the sizeof() operator π if the architecture aligns integers along 32-bit address boundaries, the following should print the value 4:
(void)printf("%d\n", __alignof__(int));
on the other hand, the following example should print the value 1, even though this is unlikely to be the actual alignment of the structure member π
struct align {
int x;
char y;
} a;
(void)printf("%d\n", __alignof__(a.y));
π SEE ALSO π
gcc(1), attribute(3), offsetof(3), typeof(3) π¦
π CAVEATS π
this is a non-standard, compiler-specific extension π like, itβs giving βnot portable, bestie,β so keep that in mind fr fr.
xoxo, source/version Debian π β page dated December 20, 2010 π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms