Some old glibcs <wctype.h> require <stddef.h> to provide wint_t, accomodate them.
Unified · Split
| @@ -26,3 +26,18 @@ typedef unsigned long long int uint64_t; · 25 unmodified lines | ||
| 26 | 26 | void *alloca(size_t size); |
| 27 | 27 | |
| 28 | 28 | #endif |
| 29 | + | |
| 30 | +/* Older glibc require a wint_t from <stddef.h> (when requested | |
| 31 | + by __need_wint_t, as otherwise stddef.h isn't allowed to | |
| 32 | + define this type). Note that this must be outside the normal | |
| 33 | + _STDDEF_H guard, so that it works even when we've included the file | |
| 34 | + already (without requring wint_t). Some other libs define _WINT_T | |
| 35 | + if they've already provided that type, so we can use that as guard. | |
| 36 | + TCC defines __WINT_TYPE__ for us. */ | |
| 37 | +#if defined (__need_wint_t) | |
| 38 | +#ifndef _WINT_T | |
| 39 | +#define _WINT_T | |
| 40 | +typedef __WINT_TYPE__ wint_t; | |
| 41 | +#endif | |
| 42 | +#undef __need_wint_t | |
| 43 | +#endif | |
| @@ -988,8 +988,17 @@ LIBTCCAPI TCCState *tcc_new(void) · 987 unmodified lines | ||
| 988 | 988 | |
| 989 | 989 | #ifdef TCC_TARGET_PE |
| 990 | 990 | tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short"); |
| 991 | + tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short"); | |
| 991 | 992 | #else |
| 992 | 993 | tcc_define_symbol(s, "__WCHAR_TYPE__", "int"); |
| 994 | + /* wint_t is unsigned int by default, but (signed) int on BSDs | |
| 995 | + and unsigned short on windows. Other OSes might have still | |
| 996 | + other conventions, sigh. */ | |
| 997 | +#if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) | |
| 998 | + tcc_define_symbol(s, "__WINT_TYPE__", "int"); | |
| 999 | +#else | |
| 1000 | + tcc_define_symbol(s, "__WINT_TYPE__", "unsigned int"); | |
| 1001 | +#endif | |
| 993 | 1002 | #endif |
| 994 | 1003 | |
| 995 | 1004 | #ifndef TCC_TARGET_PE |