Hash :
0804812c
Author :
Date :
2022-09-13T17:29:36
stdalign: alignas and alignof are C23 keywords * m4/stdalign.m4 (gl_STDALIGN_H): Check also whether alignas and alignof are keywords and so don’t need stdalign.h, and define HAVE_C_ALIGNASOF if so. If not, arrange for config.h to #define alignas and alignof by including <stdalign.h>. * modules/stdalign: No need to include <stdalign.h>. * tests/test-stdalign.c: Do not include stdalign.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
@node stdalign.h
@section @file{stdalign.h}
POSIX specification:@* Not in POSIX yet, but we expect it will be.
ISO C11 (latest free draft
@url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf})
sections 6.5.3.4, 6.7.5, 7.15.
C++11 (latest free draft
@url{http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf})
section 18.10.
Gnulib module: stdalign
Portability problems fixed by Gnulib:
@itemize
@item
On older C platforms @code{<stdalign.h>} must be included before using
@code{alignas} or @code{alignof}. For example, GCC versions before 13 do not
support these keywords, which were standardized by C23.
@item
This header file is missing on many platforms:
FreeBSD 6.4, NetBSD 7.1, OpenBSD 6.7, Minix 3.3.0, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, mingw, MSVC 14, Android 9.0.
@item
Clang 3.0's @code{<stdalign.h>} does not define @code{alignof}.
@item
The @code{alignof} macro returns too large values for
the types @code{double} and @code{long long} in GCC 4.7.0.
@item
Older C platforms might not support the obsolescent
@code{_Alignas} and @code{_Alignof} keywords or macros.
This portability problem should not matter with code using this module,
as such code should use @code{alignas} and @code{alignof} instead.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
In C11 and later, the operand of @code{alignof} must be a
parenthesized type. Recent versions of GCC support an extension in
which the operand can also be a unary expression, as with
@code{sizeof}. The Gnulib substitute does not support this extension.
@item
On most pre-C11 platforms, the operand of
@code{alignof} cannot be a structure type containing a
flexible array member.
@item
The @code{alignas} keyword or macro is not always supported.
Supported compilers include any compiler supporting C11 or later,
which includes GCC, IBM C, Sun C 5.9 and later,
and MSVC 7.0 and later.
@item
Some compilers do not support alignment via
@code{alignas} of @code{auto} variables (i.e.,
variables on the stack). They diagnose and ignore the alignment: Sun
C 5.11.
@item
Some linkers do not support operands of @code{alignas}
that are greater than 8: mingw.
@item
Some compilers require the operand of @code{alignas}
to be a single integer constant, not an expression: MSVC 7.0 through
at least 10.0.
@item
The Sun C 5.13 (2014) compiler sometimes mishandles the alignment of multiple
external variables that are declared close together with
@code{alignas}. The bug is fixed in Sun C 5.15, also known as Oracle
Developer Studio 12.6 (2017).
@item
@code{<stdalign.h>} must be #included before @code{_Alignas} and
@code{_Alignof} can be used.
@item
In C11 and C17, @code{<stdalign.h>} defines the macros
@code{__alignas_is_defined} and
@code{__alignof_is_defined} to 1.
In C23, these macros are not defined.
@item
You cannot assume that @code{alignas} and @code{alignof} are reserved words;
they might be macros.
@end itemize