[cfe-commits] [Review request][PR7955] Fix wint_t stuff on stddef.h or cygming

NAKAMURA Takumi geek4civic at gmail.com
Wed Oct 13 18:15:53 PDT 2010


I had missed __WINT_TYPE__ is predefined also on cygming.

An alternative patch is attached.

> wint_t should be defined whenever <stddef.h> is included with __need_wint_t,
> and stddef.h should provide wint_t, on cygming.

I think it would be essential, though, I am not special of C standards.

..Takumi

/* for example */
#ifndef __WINT_TYPE__
#error
#endif

#include <stddef.h>

/* wint_t should not be available here */

#define __need_wint_t
#include <stddef.h>

/* wint_t should be available here */
wint_t *foo = (__WINT_TYPE__ *)0xDEADBEEF;

#ifdef __need_wint_t
#error
#endif

/* It should be able to request wint_t again */
#define __need_wint_t
#include <stddef.h>



2010/10/11 NAKAMURA Takumi <geek4civic at gmail.com>:
> Good midnight guys!
>
> I will post patches for cygwin and mingw. I think they would be
> essential to selfbuild clang on cygming.
>
> wint_t should be defined whenever <stddef.h> is included with __need_wint_t,
> and stddef.h should provide wint_t, on cygming.
>
>
> ...Takumi
>
-------------- next part --------------
diff --git a/lib/Headers/stddef.h b/lib/Headers/stddef.h
index 84ec1a7..7cc0bc1 100644
--- a/lib/Headers/stddef.h
+++ b/lib/Headers/stddef.h
@@ -46,13 +46,16 @@ typedef __WCHAR_TYPE__ wchar_t;
 #define NULL ((void*)0)
 #endif
 
-// Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
-// __WINT_TYPE__ directly; accomodate both by requiring __need_wint_t
-#if defined(__need_wint_t) && !defined(_WINT_T)
-#define _WINT_T
-typedef __WINT_TYPE__ wint_t;
-#endif
-
 #define offsetof(t, d) __builtin_offsetof(t, d)
 
 #endif /* __STDDEF_H */
+
+/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
+__WINT_TYPE__ directly; accomodate both by requiring __need_wint_t */
+#if defined(__need_wint_t)
+#if !defined(_WINT_T)
+#define _WINT_T
+typedef __WINT_TYPE__ wint_t;
+#endif /* _WINT_T */
+#undef __need_wint_t
+#endif /* __need_wint_t */


More information about the cfe-commits mailing list