apply-from-gmane: fall back to three-way merges
[msysgit.git] / mingw / include / tchar.h
blobf680562636f096e7d7cba8a2a712f578c162f553
1 /*
2 * tchar.h
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
18 * names).
22 #ifndef _TCHAR_H_
23 #define _TCHAR_H_
25 /* All the headers include this file. */
26 #include <_mingw.h>
29 * NOTE: This tests _UNICODE, which is different from the UNICODE define
30 * used to differentiate Win32 API calls.
32 #ifdef _UNICODE
35 * Include <wchar.h> for wchar_t and WEOF if _UNICODE.
37 #include <wchar.h>
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
44 #ifndef RC_INVOKED
45 typedef wchar_t TCHAR;
46 typedef wchar_t _TCHAR;
47 #endif /* Not RC_INVOKED */
48 #define _TCHAR_DEFINED
49 #endif
52 * Use _TEOF instead of EOF or WEOF. It will be appropriately translated if
53 * _UNICODE is correctly defined (or not).
55 #define _TEOF WEOF
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
61 * notice.
63 #define __TEXT(q) L##q
65 /* for porting from other Windows compilers */
66 #if 0 /* no wide startup module */
67 #define _tmain wmain
68 #define _tWinMain wWinMain
69 #define _tenviron _wenviron
70 #define __targv __wargv
71 #endif
74 * Unicode functions
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 _tscanf wscanf
85 #define _ftscanf fwscanf
86 #define _stscanf swscanf
87 #define _fgettc fgetwc
88 #define _fgettchar _fgetwchar
89 #define _fgetts fgetws
90 #define _fputtc fputwc
91 #define _fputtchar _fputwchar
92 #define _fputts fputws
93 #define _gettc getwc
94 #define _getts _getws
95 #define _puttc putwc
96 #define _puttchar putwchar
97 #define _putts _putws
98 #define _ungettc ungetwc
99 #define _tcstod wcstod
100 #define _tcstol wcstol
101 #define _tcstoul wcstoul
102 #define _itot _itow
103 #define _ltot _ltow
104 #define _ultot _ultow
105 #define _ttoi _wtoi
106 #define _ttol _wtol
107 #define _tcscat wcscat
108 #define _tcschr wcschr
109 #define _tcscmp wcscmp
110 #define _tcscpy wcscpy
111 #define _tcscspn wcscspn
112 #define _tcslen wcslen
113 #define _tcsncat wcsncat
114 #define _tcsncmp wcsncmp
115 #define _tcsncpy wcsncpy
116 #define _tcspbrk wcspbrk
117 #define _tcsrchr wcsrchr
118 #define _tcsspn wcsspn
119 #define _tcsstr wcsstr
120 #define _tcstok wcstok
121 #define _tcsdup _wcsdup
122 #define _tcsicmp _wcsicmp
123 #define _tcsnicmp _wcsnicmp
124 #define _tcsnset _wcsnset
125 #define _tcsrev _wcsrev
126 #define _tcsset _wcsset
127 #define _tcslwr _wcslwr
128 #define _tcsupr _wcsupr
129 #define _tcsxfrm wcsxfrm
130 #define _tcscoll wcscoll
131 #define _tcsicoll _wcsicoll
132 #define _istalpha iswalpha
133 #define _istupper iswupper
134 #define _istlower iswlower
135 #define _istdigit iswdigit
136 #define _istxdigit iswxdigit
137 #define _istspace iswspace
138 #define _istpunct iswpunct
139 #define _istalnum iswalnum
140 #define _istprint iswprint
141 #define _istgraph iswgraph
142 #define _istcntrl iswcntrl
143 #define _istascii iswascii
144 #define _totupper towupper
145 #define _totlower towlower
146 #define _tcsftime wcsftime
147 /* Macro functions */
148 #define _tcsdec _wcsdec
149 #define _tcsinc _wcsinc
150 #define _tcsnbcnt _wcsncnt
151 #define _tcsnccnt _wcsncnt
152 #define _tcsnextc _wcsnextc
153 #define _tcsninc _wcsninc
154 #define _tcsspnp _wcsspnp
155 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
156 #define _wcsinc(_wcs) ((_wcs)+1)
157 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
158 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
159 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
160 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
162 #if 1 /* defined __MSVCRT__ */
164 * These wide functions not in crtdll.dll.
165 * Define macros anyway so that _wfoo rather than _tfoo is undefined
167 #define _ttoi64 _wtoi64
168 #define _i64tot _i64tow
169 #define _ui64tot _ui64tow
170 #define _tasctime _wasctime
171 #define _tctime _wctime
172 #define _tstrdate _wstrdate
173 #define _tstrtime _wstrtime
174 #define _tutime _wutime
175 #define _tcsnccoll _wcsncoll
176 #define _tcsncoll _wcsncoll
177 #define _tcsncicoll _wcsnicoll
178 #define _tcsnicoll _wcsnicoll
179 #define _taccess _waccess
180 #define _tchmod _wchmod
181 #define _tcreat _wcreat
182 #define _tfindfirst _wfindfirst
183 #define _tfindnext _wfindnext
184 #define _tfdopen _wfdopen
185 #define _tfopen _wfopen
186 #define _tfreopen _wfreopen
187 #define _tfsopen _wfsopen
188 #define _tgetenv _wgetenv
189 #define _tputenv _wputenv
190 #define _tsearchenv _wsearchenv
191 #define _tsystem _wsystem
192 #define _tmakepath _wmakepath
193 #define _tsplitpath _wsplitpath
194 #define _tfullpath _wfullpath
195 #define _tmktemp _wmktemp
196 #define _topen _wopen
197 #define _tremove _wremove
198 #define _trename _wrename
199 #define _tsopen _wsopen
200 #define _tsetlocale _wsetlocale
201 #define _tunlink _wunlink
202 #define _tfinddata_t _wfinddata_t
203 #define _tfindfirsti64 _wfindfirsti64
204 #define _tfindnexti64 _wfindnexti64
205 #define _tfinddatai64_t _wfinddatai64_t
206 #define _tchdir _wchdir
207 #define _tgetcwd _wgetcwd
208 #define _tgetdcwd _wgetdcwd
209 #define _tmkdir _wmkdir
210 #define _trmdir _wrmdir
211 #define _tstat _wstat
212 #define _tstati64 _wstati64
213 #define _tstat64 _wstat64
214 #endif /* __MSVCRT__ */
216 /* dirent structures and functions */
217 #define _tdirent _wdirent
218 #define _TDIR _WDIR
219 #define _topendir _wopendir
220 #define _tclosedir _wclosedir
221 #define _treaddir _wreaddir
222 #define _trewinddir _wrewinddir
223 #define _ttelldir _wtelldir
224 #define _tseekdir _wseekdir
226 #else /* Not _UNICODE */
229 * TCHAR, the type you should use instead of char.
231 #ifndef _TCHAR_DEFINED
232 #ifndef RC_INVOKED
233 typedef char TCHAR;
234 typedef char _TCHAR;
235 #endif
236 #define _TCHAR_DEFINED
237 #endif
240 * _TEOF, the constant you should use instead of EOF.
242 #define _TEOF EOF
245 * __TEXT is a private macro whose specific use is to force the expansion of a
246 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
247 * macro within your programs. It's name and function could change without
248 * notice.
250 #define __TEXT(q) q
252 /* for porting from other Windows compilers */
253 #define _tmain main
254 #define _tWinMain WinMain
255 #define _tenviron _environ
256 #define __targv __argv
259 * Non-unicode (standard) functions
262 #define _tprintf printf
263 #define _ftprintf fprintf
264 #define _stprintf sprintf
265 #define _sntprintf _snprintf
266 #define _vtprintf vprintf
267 #define _vftprintf vfprintf
268 #define _vstprintf vsprintf
269 #define _vsntprintf _vsnprintf
270 #define _tscanf scanf
271 #define _ftscanf fscanf
272 #define _stscanf sscanf
273 #define _fgettc fgetc
274 #define _fgettchar _fgetchar
275 #define _fgetts fgets
276 #define _fputtc fputc
277 #define _fputtchar _fputchar
278 #define _fputts fputs
279 #define _tfdopen _fdopen
280 #define _tfopen fopen
281 #define _tfreopen freopen
282 #define _tfsopen _fsopen
283 #define _tgetenv getenv
284 #define _tputenv _putenv
285 #define _tsearchenv _searchenv
286 #define _tsystem system
287 #define _tmakepath _makepath
288 #define _tsplitpath _splitpath
289 #define _tfullpath _fullpath
290 #define _gettc getc
291 #define _getts gets
292 #define _puttc putc
293 #define _puttchar putchar
294 #define _putts puts
295 #define _ungettc ungetc
296 #define _tcstod strtod
297 #define _tcstol strtol
298 #define _tcstoul strtoul
299 #define _itot _itoa
300 #define _ltot _ltoa
301 #define _ultot _ultoa
302 #define _ttoi atoi
303 #define _ttol atol
304 #define _tcscat strcat
305 #define _tcschr strchr
306 #define _tcscmp strcmp
307 #define _tcscpy strcpy
308 #define _tcscspn strcspn
309 #define _tcslen strlen
310 #define _tcsncat strncat
311 #define _tcsncmp strncmp
312 #define _tcsncpy strncpy
313 #define _tcspbrk strpbrk
314 #define _tcsrchr strrchr
315 #define _tcsspn strspn
316 #define _tcsstr strstr
317 #define _tcstok strtok
318 #define _tcsdup _strdup
319 #define _tcsicmp _stricmp
320 #define _tcsnicmp _strnicmp
321 #define _tcsnset _strnset
322 #define _tcsrev _strrev
323 #define _tcsset _strset
324 #define _tcslwr _strlwr
325 #define _tcsupr _strupr
326 #define _tcsxfrm strxfrm
327 #define _tcscoll strcoll
328 #define _tcsicoll _stricoll
329 #define _istalpha isalpha
330 #define _istupper isupper
331 #define _istlower islower
332 #define _istdigit isdigit
333 #define _istxdigit isxdigit
334 #define _istspace isspace
335 #define _istpunct ispunct
336 #define _istalnum isalnum
337 #define _istprint isprint
338 #define _istgraph isgraph
339 #define _istcntrl iscntrl
340 #define _istascii isascii
341 #define _totupper toupper
342 #define _totlower tolower
343 #define _tasctime asctime
344 #define _tctime ctime
345 #define _tstrdate _strdate
346 #define _tstrtime _strtime
347 #define _tutime _utime
348 #define _tcsftime strftime
349 /* Macro functions */
350 #define _tcsdec _strdec
351 #define _tcsinc _strinc
352 #define _tcsnbcnt _strncnt
353 #define _tcsnccnt _strncnt
354 #define _tcsnextc _strnextc
355 #define _tcsninc _strninc
356 #define _tcsspnp _strspnp
357 #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
358 #define _strinc(_str) ((_str)+1)
359 #define _strnextc(_str) ((unsigned int) *(_str))
360 #define _strninc(_str, _inc) (((_str)+(_inc)))
361 #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
362 #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
364 #define _tchmod _chmod
365 #define _tcreat _creat
366 #define _tfindfirst _findfirst
367 #define _tfindnext _findnext
368 #define _tmktemp _mktemp
369 #define _topen _open
370 #define _taccess _access
371 #define _tremove remove
372 #define _trename rename
373 #define _tsopen _sopen
374 #define _tsetlocale setlocale
375 #define _tunlink _unlink
376 #define _tfinddata_t _finddata_t
377 #define _tchdir _chdir
378 #define _tgetcwd _getcwd
379 #define _tgetdcwd _getdcwd
380 #define _tmkdir _mkdir
381 #define _trmdir _rmdir
382 #define _tstat _stat
384 #if 1 /* defined __MSVCRT__ */
385 /* Not in crtdll.dll. Define macros anyway? */
386 #define _ttoi64 _atoi64
387 #define _i64tot _i64toa
388 #define _ui64tot _ui64toa
389 #define _tcsnccoll _strncoll
390 #define _tcsncoll _strncoll
391 #define _tcsncicoll _strnicoll
392 #define _tcsnicoll _strnicoll
393 #define _tfindfirsti64 _findfirsti64
394 #define _tfindnexti64 _findnexti64
395 #define _tfinddatai64_t _finddatai64_t
396 #define _tstati64 _stati64
397 #define _tstat64 _stat64
398 #endif /* __MSVCRT__ */
400 /* dirent structures and functions */
401 #define _tdirent dirent
402 #define _TDIR DIR
403 #define _topendir opendir
404 #define _tclosedir closedir
405 #define _treaddir readdir
406 #define _trewinddir rewinddir
407 #define _ttelldir telldir
408 #define _tseekdir seekdir
410 #endif /* Not _UNICODE */
413 * UNICODE a constant string when _UNICODE is defined else returns the string
414 * unmodified. Also defined in w32api/winnt.h.
416 #define _TEXT(x) __TEXT(x)
417 #define _T(x) __TEXT(x)
419 #endif /* Not _TCHAR_H_ */