mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-13 05:10:07 +08:00
Declare wint_t in <stddef.h> when needed
Some old glibcs <wctype.h> require <stddef.h> to provide wint_t, accomodate them.
This commit is contained in:
parent
0e43f3aef4
commit
0961a38493
@ -26,3 +26,18 @@ typedef unsigned long long int uint64_t;
|
|||||||
void *alloca(size_t size);
|
void *alloca(size_t size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Older glibc require a wint_t from <stddef.h> (when requested
|
||||||
|
by __need_wint_t, as otherwise stddef.h isn't allowed to
|
||||||
|
define this type). Note that this must be outside the normal
|
||||||
|
_STDDEF_H guard, so that it works even when we've included the file
|
||||||
|
already (without requring wint_t). Some other libs define _WINT_T
|
||||||
|
if they've already provided that type, so we can use that as guard.
|
||||||
|
TCC defines __WINT_TYPE__ for us. */
|
||||||
|
#if defined (__need_wint_t)
|
||||||
|
#ifndef _WINT_T
|
||||||
|
#define _WINT_T
|
||||||
|
typedef __WINT_TYPE__ wint_t;
|
||||||
|
#endif
|
||||||
|
#undef __need_wint_t
|
||||||
|
#endif
|
||||||
|
9
libtcc.c
9
libtcc.c
@ -988,8 +988,17 @@ LIBTCCAPI TCCState *tcc_new(void)
|
|||||||
|
|
||||||
#ifdef TCC_TARGET_PE
|
#ifdef TCC_TARGET_PE
|
||||||
tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
|
tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
|
||||||
|
tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short");
|
||||||
#else
|
#else
|
||||||
tcc_define_symbol(s, "__WCHAR_TYPE__", "int");
|
tcc_define_symbol(s, "__WCHAR_TYPE__", "int");
|
||||||
|
/* wint_t is unsigned int by default, but (signed) int on BSDs
|
||||||
|
and unsigned short on windows. Other OSes might have still
|
||||||
|
other conventions, sigh. */
|
||||||
|
#if defined(__FreeBSD__) || defined (__FreeBSD_kernel__)
|
||||||
|
tcc_define_symbol(s, "__WINT_TYPE__", "int");
|
||||||
|
#else
|
||||||
|
tcc_define_symbol(s, "__WINT_TYPE__", "unsigned int");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TCC_TARGET_PE
|
#ifndef TCC_TARGET_PE
|
||||||
|
Loading…
Reference in New Issue
Block a user