Hi,<br><br>I'm not sure if this is related to <a href="http://llvm.org/bugs/show_bug.cgi?id=7571">http://llvm.org/bugs/show_bug.cgi?id=7571</a> mentioned in the thread "[PATCH] 7571: stddef.h and wint_t".<br>
I sent it to cfe-dev and have not gotten any opinions about whether this is the right fix. I thought I'd send it to cfe-commits for review. If you think that's the right solution, I have a patch attached.<br><br>Regards,<br>
Ahmed<br><br><br>---------- Forwarded message ----------<br>From: Ahmed Badran <<a href="mailto:ahmed.badran@gmail.com">ahmed.badran@gmail.com</a>><br>Date: Fri, Jul 9, 2010 at 7:45 PM<br>Subject: Clang fails to compile code that works with gcc on windows due to wint_t not defined<br>
To: <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><br><br>Hi,<br><br>I am trying to use clang to compile a very simple hello world on Windows<br>and compilation is failing due to wint_t not being defined.<br>
<br>Here are the particulars of my environment, I am trying it on Cygwin,<br>with versions of llvm & clang that are a couple days old. I've checked<br>out the copies and manually compiled and installed them on Cygwin (so<br>
they are not native Windows builds).<br><br>After tracing through the header files I came to the fragments that<br>actually define wint_t:<br><br><br>>From Gcc's stddef.h:<br><br>#if defined (__need_wint_t)<br>#ifndef _WINT_T<br>
#define _WINT_T<br><br>#ifndef __WINT_TYPE__<br>#define __WINT_TYPE__ unsigned int<br>#endif<br>typedef __WINT_TYPE__ wint_t;<br>#endif<br>#undef __need_wint_t<br>#endif<br><br><br>In clang's stddef.h, the equivalent is:<br>
<br>// Some C libraries expect to see a wint_t here. Others (notably MinGW)<br>will use<br>// __WINT_TYPE__ directly; accomodate both by requiring __need_wint_t<br>#if defined(__need_wint_t) && !defined(_WINT_T)<br>
#define _WINT_T<br>typedef __WINT_TYPE__ wint_t;<br>#endif<br><br><br>Now, what's happening is that through the inclusion chain, Gcc's<br>stddef.h is included multiple times, each time sort of enabling an extra<br>
part of the file, while clang's stddef.h is included only once at the<br>very beginning through stdio.h before __need_wint_t is defined. Later on<br>when __need_wint_t actually gets defined and stddef.h is included again,<br>
the guard directive prevents it from being read and thus wint_t never<br>gets defined.<br><br>I'm not sure what's the best way to solve this problem. I do not want to<br>go and start locally hacking the include files, I know they will change<br>
down the road and thus whatever will compile after my hacks will break<br>again in the future.<br><br>I have attached the following formatted patch, if you guys think that's<br>a valid solution, I'll go ahead and send if to the cfe-commits list for<br>
review.<br><br>+#if (!defined(__STDDEF_H) || defined(__need_wint_t))<br> #ifndef __STDDEF_H<br> #define __STDDEF_H<br>+#endif<br><br><br>Regards,<br>Ahmed<br><br>