[clang] [clang][modules] giving the __stddef_ headers their own modules can cause redeclaration errors with -fbuiltin-headers-in-system-modules (PR #84127)
Ian Anderson via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 12 10:38:17 PDT 2024
================
@@ -7,6 +7,11 @@
*===-----------------------------------------------------------------------===
*/
-#ifndef offsetof
+/*
+ * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
+ * and needs to behave as if it was textual.
+ */
+#if !defined(offsetof) || \
+ (__has_feature(modules) && !__building_module(_Builtin_stddef))
----------------
ian-twilightcoder wrote:
Oh I see what you mean. When the Darwin module builds, it will build <stddef.h> which will include <__stddef_offsetof.h>. It will bypass the header guard and (re)define `offsetof`. The Darwin module will also build <sys/_types/_offsetof.h>, so which one gets used is undefined, but the Darwin module will be the single definer of `offsetof`. It's a little weird, but this actually matches the LLVM 17 behavior.
https://github.com/llvm/llvm-project/pull/84127
More information about the cfe-commits
mailing list