3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
7 * Unicode mapping layer for the standard C library. By including this
8 * file and using the 't' names for string functions
9 * (eg. _tprintf) you can make code which can be easily adapted to both
10 * Unicode and non-unicode environments. In a unicode enabled compile define
11 * _UNICODE before including tchar.h, otherwise the standard non-unicode
12 * library functions will be used.
14 * Note that you still need to include string.h or stdlib.h etc. to define
15 * the appropriate functions. Also note that there are several defines
16 * included for non-ANSI functions which are commonly available (but using
17 * the convention of prepending an underscore to non-ANSI library function
25 /* All the headers include this file. */
29 * NOTE: This tests _UNICODE, which is different from the UNICODE define
30 * used to differentiate Win32 API calls.
35 * Include <wchar.h> for wchar_t and WEOF if _UNICODE.
40 * Use TCHAR instead of char or wchar_t. It will be appropriately translated
41 * if _UNICODE is correctly defined (or not).
43 #ifndef _TCHAR_DEFINED
45 typedef wchar_t TCHAR;
46 typedef wchar_t _TCHAR;
47 #endif /* Not RC_INVOKED */
48 #define _TCHAR_DEFINED
52 * Use _TEOF instead of EOF or WEOF. It will be appropriately translated if
53 * _UNICODE is correctly defined (or not).
58 * __TEXT is a private macro whose specific use is to force the expansion of a
59 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
60 * macro within your programs. It's name and function could change without
63 #define __TEXT(q) L##q
65 /* for porting from other Windows compilers */
66 #if 0 /* no wide startup module */
68 #define _tWinMain wWinMain
69 #define _tenviron _wenviron
70 #define __targv __wargv
76 #define _tprintf wprintf
77 #define _ftprintf fwprintf
78 #define _stprintf swprintf
79 #define _sntprintf _snwprintf
80 #define _vtprintf vwprintf
81 #define _vftprintf vfwprintf
82 #define _vstprintf vswprintf
83 #define _vsntprintf _vsnwprintf
84 #define _vsctprintf _vscwprintf
85 #define _tscanf wscanf
86 #define _ftscanf fwscanf
87 #define _stscanf swscanf
88 #define _fgettc fgetwc
89 #define _fgettchar _fgetwchar
90 #define _fgetts fgetws
91 #define _fputtc fputwc
92 #define _fputtchar _fputwchar
93 #define _fputts fputws
97 #define _puttchar putwchar
99 #define _ungettc ungetwc
100 #define _tcstod wcstod
101 #define _tcstol wcstol
102 #define _tcstoul wcstoul
105 #define _ultot _ultow
108 #define _tcscat wcscat
109 #define _tcschr wcschr
110 #define _tcscmp wcscmp
111 #define _tcscpy wcscpy
112 #define _tcscspn wcscspn
113 #define _tcslen wcslen
114 #define _tcsncat wcsncat
115 #define _tcsncmp wcsncmp
116 #define _tcsncpy wcsncpy
117 #define _tcspbrk wcspbrk
118 #define _tcsrchr wcsrchr
119 #define _tcsspn wcsspn
120 #define _tcsstr wcsstr
121 #define _tcstok wcstok
122 #define _tcsdup _wcsdup
123 #define _tcsicmp _wcsicmp
124 #define _tcsnicmp _wcsnicmp
125 #define _tcsnset _wcsnset
126 #define _tcsrev _wcsrev
127 #define _tcsset _wcsset
128 #define _tcslwr _wcslwr
129 #define _tcsupr _wcsupr
130 #define _tcsxfrm wcsxfrm
131 #define _tcscoll wcscoll
132 #define _tcsicoll _wcsicoll
133 #define _istalpha iswalpha
134 #define _istupper iswupper
135 #define _istlower iswlower
136 #define _istdigit iswdigit
137 #define _istxdigit iswxdigit
138 #define _istspace iswspace
139 #define _istpunct iswpunct
140 #define _istalnum iswalnum
141 #define _istprint iswprint
142 #define _istgraph iswgraph
143 #define _istcntrl iswcntrl
144 #define _istascii iswascii
145 #define _totupper towupper
146 #define _totlower towlower
147 #define _tcsftime wcsftime
148 /* Macro functions */
149 #define _tcsdec _wcsdec
150 #define _tcsinc _wcsinc
151 #define _tcsnbcnt _wcsncnt
152 #define _tcsnccnt _wcsncnt
153 #define _tcsnextc _wcsnextc
154 #define _tcsninc _wcsninc
155 #define _tcsspnp _wcsspnp
156 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
157 #define _wcsinc(_wcs) ((_wcs)+1)
158 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
159 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
160 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
161 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
163 #if 1 /* defined __MSVCRT__ */
165 * These wide functions not in crtdll.dll.
166 * Define macros anyway so that _wfoo rather than _tfoo is undefined
168 #define _ttoi64 _wtoi64
169 #define _i64tot _i64tow
170 #define _ui64tot _ui64tow
171 #define _tasctime _wasctime
172 #define _tctime _wctime
173 #if __MSVCRT_VERSION__ >= 0x0800
174 #define _tctime32 _wctime32
175 #define _tctime64 _wctime64
176 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
177 #define _tstrdate _wstrdate
178 #define _tstrtime _wstrtime
179 #define _tutime _wutime
180 #if __MSVCRT_VERSION__ >= 0x0800
181 #define _tutime64 _wutime64
182 #define _tutime32 _wutime32
183 #endif /* __MSVCRT_VERSION__ > 0x0800 */
184 #define _tcsnccoll _wcsncoll
185 #define _tcsncoll _wcsncoll
186 #define _tcsncicoll _wcsnicoll
187 #define _tcsnicoll _wcsnicoll
188 #define _taccess _waccess
189 #define _tchmod _wchmod
190 #define _tcreat _wcreat
191 #define _tfindfirst _wfindfirst
192 #define _tfindnext _wfindnext
193 #if __MSVCRT_VERSION__ >= 0x0800
194 #define _tfindfirst64 _wfindfirst64
195 #define _tfindfirst32 _wfindfirst32
196 #define _tfindnext64 _wfindnext64
197 #define _tfindnext32 _wfindnext32
198 #endif /* __MSVCRT_VERSION__ > 0x0800 */
199 #define _tfdopen _wfdopen
200 #define _tfopen _wfopen
201 #define _tfreopen _wfreopen
202 #define _tfsopen _wfsopen
203 #define _tgetenv _wgetenv
204 #define _tputenv _wputenv
205 #define _tsearchenv _wsearchenv
206 #define _tsystem _wsystem
207 #define _tmakepath _wmakepath
208 #define _tsplitpath _wsplitpath
209 #define _tfullpath _wfullpath
210 #define _tmktemp _wmktemp
211 #define _topen _wopen
212 #define _tremove _wremove
213 #define _trename _wrename
214 #define _tsopen _wsopen
215 #define _tsetlocale _wsetlocale
216 #define _tunlink _wunlink
217 #define _tfinddata_t _wfinddata_t
218 #define _tfindfirsti64 _wfindfirsti64
219 #define _tfindnexti64 _wfindnexti64
220 #define _tfinddatai64_t _wfinddatai64_t
221 #if __MSVCRT_VERSION__ >= 0x0601
222 #define _tfinddata64_t _wfinddata64_t
224 #if __MSVCRT_VERSION__ >= 0x0800
225 #define _tfinddata32_t _wfinddata32_t
226 #define _tfinddata32i64_t _wfinddata32i64_t
227 #define _tfinddata64i32_t _wfinddata64i32_t
228 #define _tfindfirst32i64 _wfindfirst32i64
229 #define _tfindfirst64i32 _wfindfirst64i32
230 #define _tfindnext32i64 _wfindnext32i64
231 #define _tfindnext64i32 _wfindnext64i32
232 #endif /* __MSVCRT_VERSION__ > 0x0800 */
233 #define _tchdir _wchdir
234 #define _tgetcwd _wgetcwd
235 #define _tgetdcwd _wgetdcwd
236 #define _tmkdir _wmkdir
237 #define _trmdir _wrmdir
238 #define _tstat _wstat
239 #define _tstati64 _wstati64
240 #define _tstat64 _wstat64
241 #if __MSVCRT_VERSION__ >= 0x0800
242 #define _tstat32 _wstat32
243 #define _tstat32i64 _wstat32i64
244 #define _tstat64i32 _wstat64i32
245 #endif /* __MSVCRT_VERSION__ > 0x0800 */
246 #endif /* __MSVCRT__ */
248 /* dirent structures and functions */
249 #define _tdirent _wdirent
251 #define _topendir _wopendir
252 #define _tclosedir _wclosedir
253 #define _treaddir _wreaddir
254 #define _trewinddir _wrewinddir
255 #define _ttelldir _wtelldir
256 #define _tseekdir _wseekdir
258 #else /* Not _UNICODE */
261 * TCHAR, the type you should use instead of char.
263 #ifndef _TCHAR_DEFINED
268 #define _TCHAR_DEFINED
272 * _TEOF, the constant you should use instead of EOF.
277 * __TEXT is a private macro whose specific use is to force the expansion of a
278 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
279 * macro within your programs. It's name and function could change without
284 /* for porting from other Windows compilers */
286 #define _tWinMain WinMain
287 #define _tenviron _environ
288 #define __targv __argv
291 * Non-unicode (standard) functions
294 #define _tprintf printf
295 #define _ftprintf fprintf
296 #define _stprintf sprintf
297 #define _sntprintf _snprintf
298 #define _vtprintf vprintf
299 #define _vftprintf vfprintf
300 #define _vstprintf vsprintf
301 #define _vsntprintf _vsnprintf
302 #define _vsctprintf _vscprintf
303 #define _tscanf scanf
304 #define _ftscanf fscanf
305 #define _stscanf sscanf
306 #define _fgettc fgetc
307 #define _fgettchar _fgetchar
308 #define _fgetts fgets
309 #define _fputtc fputc
310 #define _fputtchar _fputchar
311 #define _fputts fputs
312 #define _tfdopen _fdopen
313 #define _tfopen fopen
314 #define _tfreopen freopen
315 #define _tfsopen _fsopen
316 #define _tgetenv getenv
317 #define _tputenv _putenv
318 #define _tsearchenv _searchenv
319 #define _tsystem system
320 #define _tmakepath _makepath
321 #define _tsplitpath _splitpath
322 #define _tfullpath _fullpath
326 #define _puttchar putchar
328 #define _ungettc ungetc
329 #define _tcstod strtod
330 #define _tcstol strtol
331 #define _tcstoul strtoul
334 #define _ultot _ultoa
337 #define _tcscat strcat
338 #define _tcschr strchr
339 #define _tcscmp strcmp
340 #define _tcscpy strcpy
341 #define _tcscspn strcspn
342 #define _tcslen strlen
343 #define _tcsncat strncat
344 #define _tcsncmp strncmp
345 #define _tcsncpy strncpy
346 #define _tcspbrk strpbrk
347 #define _tcsrchr strrchr
348 #define _tcsspn strspn
349 #define _tcsstr strstr
350 #define _tcstok strtok
351 #define _tcsdup _strdup
352 #define _tcsicmp _stricmp
353 #define _tcsnicmp _strnicmp
354 #define _tcsnset _strnset
355 #define _tcsrev _strrev
356 #define _tcsset _strset
357 #define _tcslwr _strlwr
358 #define _tcsupr _strupr
359 #define _tcsxfrm strxfrm
360 #define _tcscoll strcoll
361 #define _tcsicoll _stricoll
362 #define _istalpha isalpha
363 #define _istupper isupper
364 #define _istlower islower
365 #define _istdigit isdigit
366 #define _istxdigit isxdigit
367 #define _istspace isspace
368 #define _istpunct ispunct
369 #define _istalnum isalnum
370 #define _istprint isprint
371 #define _istgraph isgraph
372 #define _istcntrl iscntrl
373 #define _istascii isascii
374 #define _totupper toupper
375 #define _totlower tolower
376 #define _tasctime asctime
377 #define _tctime ctime
378 #if __MSVCRT_VERSION__ >= 0x0800
379 #define _tctime32 _ctime32
380 #define _tctime64 _ctime64
381 #endif /* __MSVCRT_VERSION__ >= 0x0800 */
382 #define _tstrdate _strdate
383 #define _tstrtime _strtime
384 #define _tutime _utime
385 #if __MSVCRT_VERSION__ >= 0x0800
386 #define _tutime64 _utime64
387 #define _tutime32 _utime32
388 #endif /* __MSVCRT_VERSION__ > 0x0800 */
389 #define _tcsftime strftime
390 /* Macro functions */
391 #define _tcsdec _strdec
392 #define _tcsinc _strinc
393 #define _tcsnbcnt _strncnt
394 #define _tcsnccnt _strncnt
395 #define _tcsnextc _strnextc
396 #define _tcsninc _strninc
397 #define _tcsspnp _strspnp
398 #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
399 #define _strinc(_str) ((_str)+1)
400 #define _strnextc(_str) ((unsigned int) *(_str))
401 #define _strninc(_str, _inc) (((_str)+(_inc)))
402 #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
403 #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
405 #define _tchmod _chmod
406 #define _tcreat _creat
407 #define _tfindfirst _findfirst
408 #define _tfindnext _findnext
409 #if __MSVCRT_VERSION__ >= 0x0800
410 #define _tfindfirst64 _findfirst64
411 #define _tfindfirst32 _findfirst32
412 #define _tfindnext64 _findnext64
413 #define _tfindnext32 _findnext32
414 #endif /* __MSVCRT_VERSION__ > 0x0800 */
415 #define _tmktemp _mktemp
417 #define _taccess _access
418 #define _tremove remove
419 #define _trename rename
420 #define _tsopen _sopen
421 #define _tsetlocale setlocale
422 #define _tunlink _unlink
423 #define _tfinddata_t _finddata_t
424 #define _tchdir _chdir
425 #define _tgetcwd _getcwd
426 #define _tgetdcwd _getdcwd
427 #define _tmkdir _mkdir
428 #define _trmdir _rmdir
431 #if 1 /* defined __MSVCRT__ */
432 /* Not in crtdll.dll. Define macros anyway? */
433 #define _ttoi64 _atoi64
434 #define _i64tot _i64toa
435 #define _ui64tot _ui64toa
436 #define _tcsnccoll _strncoll
437 #define _tcsncoll _strncoll
438 #define _tcsncicoll _strnicoll
439 #define _tcsnicoll _strnicoll
440 #define _tfindfirsti64 _findfirsti64
441 #define _tfindnexti64 _findnexti64
442 #define _tfinddatai64_t _finddatai64_t
443 #if __MSVCRT_VERSION__ >= 0x0601
444 #define _tfinddata64_t _finddata64_t
446 #if __MSVCRT_VERSION__ >= 0x0800
447 #define _tfinddata32_t _finddata32_t
448 #define _tfinddata32i64_t _finddata32i64_t
449 #define _tfinddata64i32_t _finddata64i32_t
450 #define _tfindfirst32i64 _findfirst32i64
451 #define _tfindfirst64i32 _findfirst64i32
452 #define _tfindnext32i64 _findnext32i64
453 #define _tfindnext64i32 _findnext64i32
454 #endif /* __MSVCRT_VERSION__ > 0x0800 */
455 #define _tstati64 _stati64
456 #define _tstat64 _stat64
457 #if __MSVCRT_VERSION__ >= 0x0800
458 #define _tstat32 _stat32
459 #define _tstat32i64 _stat32i64
460 #define _tstat64i32 _stat64i32
461 #endif /* __MSVCRT_VERSION__ > 0x0800 */
462 #endif /* __MSVCRT__ */
464 /* dirent structures and functions */
465 #define _tdirent dirent
467 #define _topendir opendir
468 #define _tclosedir closedir
469 #define _treaddir readdir
470 #define _trewinddir rewinddir
471 #define _ttelldir telldir
472 #define _tseekdir seekdir
474 #endif /* Not _UNICODE */
477 * UNICODE a constant string when _UNICODE is defined else returns the string
478 * unmodified. Also defined in w32api/winnt.h.
480 #define _TEXT(x) __TEXT(x)
481 #define _T(x) __TEXT(x)
483 #endif /* Not _TCHAR_H_ */