2 @section @file{stdalign.h}
4 ISO C23 specification:@* @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf} sections 6.5.3.4, 6.7.5, 7.15.
6 C++11 specification:@* @url{https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf} section 18.10.
8 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdalign.h.html}
10 Gnulib module: alignasof
13 Portability problems fixed by Gnulib:
16 On older C platforms @code{<stdalign.h>} must be included before using
17 @code{alignas} or @code{alignof}. For example, GCC versions before 13 do not
18 support these keywords, which were standardized by C23.
19 On C23 and later platforms, @code{<stdalign.h>} has no effect and need
22 (Gnulib-using code should not include
23 @code{<stdalign.h>} without also employing Gnulib's now-deprecated
24 @code{stdalign-h} module.)
26 This header file is missing on many platforms:
27 FreeBSD 6.4, NetBSD 7.1, OpenBSD 7.5, Minix 3.3.0, AIX 7.1, HP-UX 11.31, Solaris 11.3, mingw, MSVC 14, Android 9.0.
29 Clang 3.0's @code{<stdalign.h>} does not define @code{alignof}.
31 The @code{alignof} macro returns too large values for
32 the types @code{double} and @code{long long} in GCC 4.7.0.
34 Older C platforms might not support the obsolescent
35 @code{_Alignas} and @code{_Alignof} keywords or macros.
36 This portability problem should not matter with code using this module,
37 as such code should use @code{alignas} and @code{alignof} instead.
39 In C11 and C17, @code{<stdalign.h>} defines the macros
40 @code{__alignas_is_defined} and
41 @code{__alignof_is_defined} to 1.
42 In C23, these macros are not defined.
43 This portability problem should not matter with code using Gnulib's
44 @code{alignasof} module, as such code should use @code{alignas} and
45 @code{alignof} without checking these two macros. (Gnulib's
46 now-deprecated @code{stdalign-h} module defines these two macros.)
48 @c https://github.com/llvm/llvm-project/issues/81472
49 Clang 17 does not support an @code{alignas} attribute in the
50 specifier-qualifier position of a member declaration.
53 Portability problems not fixed by Gnulib:
56 In C11 and later, the operand of @code{alignof} must be a
57 parenthesized type. Recent versions of GCC support an extension in
58 which the operand can also be a unary expression, as with
59 @code{sizeof}. The Gnulib substitute does not support this extension.
61 On most pre-C11 platforms, the operand of
62 @code{alignof} cannot be a structure type containing a
63 flexible array member.
65 The @code{alignas} keyword or macro is not always supported.
66 Supported compilers include any compiler supporting C11 or later,
67 which includes GCC, IBM C, Sun C 5.9 and later,
68 and MSVC 7.0 and later.
70 Some compilers do not support alignment via
71 @code{alignas} of @code{auto} variables (i.e.,
72 variables on the stack). They diagnose and ignore the alignment: Sun
75 Some linkers do not support operands of @code{alignas}
76 that are greater than 8: mingw.
78 Some compilers require the operand of @code{alignas}
79 to be a single integer constant, not an expression: MSVC 7.0 through
82 The Sun C 5.13 (2014) compiler sometimes mishandles the alignment of multiple
83 external variables that are declared close together with
84 @code{alignas}. The bug is fixed in Sun C 5.15, also known as Oracle
85 Developer Studio 12.6 (2017).
87 You cannot assume that @code{alignas} and @code{alignof} are reserved words;