[libcxx-commits] [PATCH] D46443: [libc++] Add missing cstdalign header

Marek Kurdej via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 9 09:46:06 PST 2021

curdeius added inline comments.

Comment at: libcxx/include/cstdalign:24
+#include <__config>
+#include <stdalign.h>
curdeius wrote:
> hubert.reinterpretcast wrote:
> > sbc100 wrote:
> > > hubert.reinterpretcast wrote:
> > > > This seems to be assuming that the underlying C library's `stdalign.h` is C++ friendly. A C11 `stdalign.h` //does// define `alignof` and `alignas` as macros.
> > > Should I just remove this `#include` then?
> > The idea would be to //add// a `stdalign.h` alongside this header that doesn't `#include_next` the underlying C library's `stdalign.h`.
> I'm not sure if that should be the solution. At least gcc's libstdc++ assumes that `stdalign.h` is C++-compatbile (cf. https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/c_global/cstdalign).
> Clang provides a compatible header: https://github.com/llvm/llvm-project/commit/8acb4044d83ecc9df81b1c9f327d5bd4325e1756.
> Gcc too of course: https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/ginclude/stdalign.h.
> MSVC's STL on the other hand, doesn't include `<stdalign.h>` (https://github.com/microsoft/STL/blob/main/stl/inc/cstdalign).
> @hubert.reinterpretcast, are you aware of an environment which has non-friendly `stdalign.h`?
FYI, musl is also C++ friendly: https://git.musl-libc.org/cgit/musl/tree/include/stdalign.h.

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list