[PATCH] D51265: Headers: fix collisions with .h files of other projects

Andrew Kelley via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 25 20:24:13 PDT 2018


andrewrk updated this revision to Diff 162574.
andrewrk added a comment.

Addressed review feedback


Repository:
  rC Clang

https://reviews.llvm.org/D51265

Files:
  lib/Headers/stdarg.h
  lib/Headers/stddef.h


Index: lib/Headers/stddef.h
===================================================================
--- lib/Headers/stddef.h
+++ lib/Headers/stddef.h
@@ -48,7 +48,12 @@
 #if !__has_feature(modules)
 #define _PTRDIFF_T
 #endif
+
+#if !defined(_PTRDIFF_T_DEFINED)
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define _PTRDIFF_T_DEFINED
+#endif
+
 #endif
 #undef __need_ptrdiff_t
 #endif /* defined(__need_ptrdiff_t) */
@@ -59,7 +64,23 @@
 #if !__has_feature(modules)
 #define _SIZE_T
 #endif
+
+#if !defined(_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DEFINED)
+#if !defined(_BSD_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DECLARED)
 typedef __SIZE_TYPE__ size_t;
+#define _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED
+#define _BSD_SIZE_T_DEFINED_
+#define _SIZE_T_DECLARED
+#endif
+#endif
+#endif
+#endif
+
+
+
 #endif
 #undef __need_size_t
 #endif /*defined(__need_size_t) */
@@ -87,7 +108,21 @@
 #define _WCHAR_T_DEFINED
 #endif
 #endif
+
+#if !defined(__INT_WCHAR_T_H)
+#if !defined(_GCC_WCHAR_T)
+#if !defined(_WCHAR_T_DECLARED)
+#if !defined(_WCHAR_T_DEFINED)
+#define __INT_WCHAR_T_H
+#define _GCC_WCHAR_T
+#define _WCHAR_T_DECLARED
+#define _WCHAR_T_DEFINED
 typedef __WCHAR_TYPE__ wchar_t;
+#endif
+#endif
+#endif
+#endif
+
 #endif
 #endif
 #undef __need_wchar_t
Index: lib/Headers/stdarg.h
===================================================================
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -26,7 +26,7 @@
 #ifndef __STDARG_H
 #define __STDARG_H
 
-#ifndef _VA_LIST
+#if !defined(_VA_LIST) && !defined(_VA_LIST_T)
 typedef __builtin_va_list va_list;
 #define _VA_LIST
 #endif
@@ -46,6 +46,7 @@
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
 typedef __builtin_va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
 #endif
 
 #endif /* __STDARG_H */


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51265.162574.patch
Type: text/x-patch
Size: 1754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180826/39343b20/attachment.bin>


More information about the cfe-commits mailing list