History

Declare wint_t in <stddef.h> when needed

Some old glibcs <wctype.h> require <stddef.h> to provide wint_t, accomodate them.

Michael Matz committed 12 years ago

Commit 0961a381 parent 0e43f3a2 files · +24 −0Browse files

Unified · Split

2 files
  1. include/stddef.h +15 −0
  2. libtcc.c +9 −0
include/stddef.h+15−0
@@ -26,3 +26,18 @@ typedef unsigned long long int uint64_t; · 25 unmodified lines
2626 void *alloca(size_t size);
2727
2828 #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
libtcc.c+9−0
@@ -988,8 +988,17 @@ LIBTCCAPI TCCState *tcc_new(void) · 987 unmodified lines
988988
989989 #ifdef TCC_TARGET_PE
990990 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
991+ tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short");
991992 #else
992993 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
9931002 #endif
9941003
9951004 #ifndef TCC_TARGET_PE

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t