[clang] [clang][modules] giving the __stddef_ headers their own modules can cause redeclaration errors with -fbuiltin-headers-in-system-modules (PR #84127)

Volodymyr Sapsai via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 10:18:29 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))
----------------
vsapsai wrote:

I was thinking about `offsetof` being defined in some header, not in the intended system one. And then we [transitively] include "\_\_stddef_offsetof.h". Does it mean that in this case "\_\_stddef_offsetof.h" is processed only when building module "_Builtin_stddef"?

https://github.com/llvm/llvm-project/pull/84127


More information about the cfe-commits mailing list