Optimize arithmetic with pointer to value on stack + constant
[tinycc/daniel.git] / win32 / include / tchar.h
blob72c1b3c8104f21e2ca06e32613999cbc6981b405
1 /*
2 * tchar.h
4 * Unicode mapping layer for the standard C library. By including this
5 * file and using the 't' names for string functions
6 * (eg. _tprintf) you can make code which can be easily adapted to both
7 * Unicode and non-unicode environments. In a unicode enabled compile define
8 * _UNICODE before including tchar.h, otherwise the standard non-unicode
9 * library functions will be used.
11 * Note that you still need to include string.h or stdlib.h etc. to define
12 * the appropriate functions. Also note that there are several defines
13 * included for non-ANSI functions which are commonly available (but using
14 * the convention of prepending an underscore to non-ANSI library function
15 * names).
17 * This file is part of the Mingw32 package.
19 * Contributors:
20 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
22 * THIS SOFTWARE IS NOT COPYRIGHTED
24 * This source code is offered for use in the public domain. You may
25 * use, modify or distribute it freely.
27 * This code is distributed in the hope that it will be useful but
28 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
29 * DISCLAIMED. This includes but is not limited to warranties of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
32 * $Revision: 1.2 $
33 * $Author: bellard $
34 * $Date: 2005/04/17 13:14:29 $
38 #ifndef _TCHAR_H_
39 #define _TCHAR_H_
41 /* All the headers include this file. */
42 #include <_mingw.h>
45 * NOTE: This tests _UNICODE, which is different from the UNICODE define
46 * used to differentiate Win32 API calls.
48 #ifdef _UNICODE
52 * Use TCHAR instead of char or wchar_t. It will be appropriately translated
53 * if _UNICODE is correctly defined (or not).
55 #ifndef _TCHAR_DEFINED
56 #ifndef RC_INVOKED
57 typedef wchar_t TCHAR;
58 typedef wchar_t _TCHAR;
59 #endif /* Not RC_INVOKED */
60 #define _TCHAR_DEFINED
61 #endif
65 * __TEXT is a private macro whose specific use is to force the expansion of a
66 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
67 * macro within your programs. It's name and function could change without
68 * notice.
70 #define __TEXT(x) L##x
72 /* for porting from other Windows compilers */
73 #if 0 // no wide startup module
74 #define _tmain wmain
75 #define _tWinMain wWinMain
76 #define _tenviron _wenviron
77 #define __targv __wargv
78 #endif
81 * Unicode functions
83 #define _tprintf wprintf
84 #define _ftprintf fwprintf
85 #define _stprintf swprintf
86 #define _sntprintf _snwprintf
87 #define _vtprintf vwprintf
88 #define _vftprintf vfwprintf
89 #define _vstprintf vswprintf
90 #define _vsntprintf _vsnwprintf
91 #define _tscanf wscanf
92 #define _ftscanf fwscanf
93 #define _stscanf swscanf
94 #define _fgettc fgetwc
95 #define _fgettchar _fgetwchar
96 #define _fgetts fgetws
97 #define _fputtc fputwc
98 #define _fputtchar _fputwchar
99 #define _fputts fputws
100 #define _gettc getwc
101 #define _getts getws
102 #define _puttc putwc
103 #define _putts putws
104 #define _ungettc ungetwc
105 #define _tcstod wcstod
106 #define _tcstol wcstol
107 #define _tcstoul wcstoul
108 #define _itot _itow
109 #define _ltot _ltow
110 #define _ultot _ultow
111 #define _ttoi _wtoi
112 #define _ttol _wtol
113 #define _tcscat wcscat
114 #define _tcschr wcschr
115 #define _tcscmp wcscmp
116 #define _tcscpy wcscpy
117 #define _tcscspn wcscspn
118 #define _tcslen wcslen
119 #define _tcsncat wcsncat
120 #define _tcsncmp wcsncmp
121 #define _tcsncpy wcsncpy
122 #define _tcspbrk wcspbrk
123 #define _tcsrchr wcsrchr
124 #define _tcsspn wcsspn
125 #define _tcsstr wcsstr
126 #define _tcstok wcstok
127 #define _tcsdup _wcsdup
128 #define _tcsicmp _wcsicmp
129 #define _tcsnicmp _wcsnicmp
130 #define _tcsnset _wcsnset
131 #define _tcsrev _wcsrev
132 #define _tcsset _wcsset
133 #define _tcslwr _wcslwr
134 #define _tcsupr _wcsupr
135 #define _tcsxfrm wcsxfrm
136 #define _tcscoll wcscoll
137 #define _tcsicoll _wcsicoll
138 #define _istalpha iswalpha
139 #define _istupper iswupper
140 #define _istlower iswlower
141 #define _istdigit iswdigit
142 #define _istxdigit iswxdigit
143 #define _istspace iswspace
144 #define _istpunct iswpunct
145 #define _istalnum iswalnum
146 #define _istprint iswprint
147 #define _istgraph iswgraph
148 #define _istcntrl iswcntrl
149 #define _istascii iswascii
150 #define _totupper towupper
151 #define _totlower towlower
152 #define _tcsftime wcsftime
153 /* Macro functions */
154 #define _tcsdec _wcsdec
155 #define _tcsinc _wcsinc
156 #define _tcsnbcnt _wcsncnt
157 #define _tcsnccnt _wcsncnt
158 #define _tcsnextc _wcsnextc
159 #define _tcsninc _wcsninc
160 #define _tcsspnp _wcsspnp
161 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
162 #define _wcsinc(_wcs) ((_wcs)+1)
163 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
164 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
165 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
166 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
168 #if 1 // defined __MSVCRT__
170 * These wide functions not in crtdll.dll.
171 * Define macros anyway so that _wfoo rather than _tfoo is undefined
173 #define _ttoi64 _wtoi64
174 #define _i64tot _i64tow
175 #define _ui64tot _ui64tow
176 #define _tasctime _wasctime
177 #define _tctime _wctime
178 #define _tstrdate _wstrdate
179 #define _tstrtime _wstrtime
180 #define _tutime _wutime
181 #define _tcsnccoll _wcsncoll
182 #define _tcsncoll _wcsncoll
183 #define _tcsncicoll _wcsnicoll
184 #define _tcsnicoll _wcsnicoll
185 #define _taccess _waccess
186 #define _tchmod _wchmod
187 #define _tcreat _wcreat
188 #define _tfindfirst _wfindfirst
189 #define _tfindnext _wfindnext
190 #define _tfopen _wfopen
191 #define _tgetenv _wgetenv
192 #define _tmktemp _wmktemp
193 #define _topen _wopen
194 #define _tremove _wremove
195 #define _trename _wrename
196 #define _tsopen _wsopen
197 #define _tsetlocale _wsetlocale
198 #define _tunlink _wunlink
199 #define _tfinddata_t _wfinddata_t
200 #define _tfindfirsti64 _wfindfirsti64
201 #define _tfindnexti64 _wfindnexti64
202 #define _tfinddatai64_t _wfinddatai64_t
203 #endif /* __MSVCRT__ */
205 #else /* Not _UNICODE */
208 * TCHAR, the type you should use instead of char.
210 #ifndef _TCHAR_DEFINED
211 #ifndef RC_INVOKED
212 typedef char TCHAR;
213 typedef char _TCHAR;
214 #endif
215 #define _TCHAR_DEFINED
216 #endif
219 * __TEXT is a private macro whose specific use is to force the expansion of a
220 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this
221 * macro within your programs. It's name and function could change without
222 * notice.
224 #define __TEXT(x) x
226 /* for porting from other Windows compilers */
227 #define _tmain main
228 #define _tWinMain WinMain
229 #define _tenviron _environ
230 #define __targv __argv
233 * Non-unicode (standard) functions
236 #define _tprintf printf
237 #define _ftprintf fprintf
238 #define _stprintf sprintf
239 #define _sntprintf _snprintf
240 #define _vtprintf vprintf
241 #define _vftprintf vfprintf
242 #define _vstprintf vsprintf
243 #define _vsntprintf _vsnprintf
244 #define _tscanf scanf
245 #define _ftscanf fscanf
246 #define _stscanf sscanf
247 #define _fgettc fgetc
248 #define _fgettchar _fgetchar
249 #define _fgetts fgets
250 #define _fputtc fputc
251 #define _fputtchar _fputchar
252 #define _fputts fputs
253 #define _tfopen fopen
254 #define _tgetenv getenv
255 #define _gettc getc
256 #define _getts gets
257 #define _puttc putc
258 #define _putts puts
259 #define _ungettc ungetc
260 #define _tcstod strtod
261 #define _tcstol strtol
262 #define _tcstoul strtoul
263 #define _itot _itoa
264 #define _ltot _ltoa
265 #define _ultot _ultoa
266 #define _ttoi atoi
267 #define _ttol atol
268 #define _tcscat strcat
269 #define _tcschr strchr
270 #define _tcscmp strcmp
271 #define _tcscpy strcpy
272 #define _tcscspn strcspn
273 #define _tcslen strlen
274 #define _tcsncat strncat
275 #define _tcsncmp strncmp
276 #define _tcsncpy strncpy
277 #define _tcspbrk strpbrk
278 #define _tcsrchr strrchr
279 #define _tcsspn strspn
280 #define _tcsstr strstr
281 #define _tcstok strtok
282 #define _tcsdup _strdup
283 #define _tcsicmp _stricmp
284 #define _tcsnicmp _strnicmp
285 #define _tcsnset _strnset
286 #define _tcsrev _strrev
287 #define _tcsset _strset
288 #define _tcslwr _strlwr
289 #define _tcsupr _strupr
290 #define _tcsxfrm strxfrm
291 #define _tcscoll strcoll
292 #define _tcsicoll _stricoll
293 #define _istalpha isalpha
294 #define _istupper isupper
295 #define _istlower islower
296 #define _istdigit isdigit
297 #define _istxdigit isxdigit
298 #define _istspace isspace
299 #define _istpunct ispunct
300 #define _istalnum isalnum
301 #define _istprint isprint
302 #define _istgraph isgraph
303 #define _istcntrl iscntrl
304 #define _istascii isascii
305 #define _totupper toupper
306 #define _totlower tolower
307 #define _tasctime asctime
308 #define _tctime ctime
309 #define _tstrdate _strdate
310 #define _tstrtime _strtime
311 #define _tutime _utime
312 #define _tcsftime strftime
313 /* Macro functions */
314 #define _tcsdec _strdec
315 #define _tcsinc _strinc
316 #define _tcsnbcnt _strncnt
317 #define _tcsnccnt _strncnt
318 #define _tcsnextc _strnextc
319 #define _tcsninc _strninc
320 #define _tcsspnp _strspnp
321 #define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
322 #define _strinc(_str) ((_str)+1)
323 #define _strnextc(_str) ((unsigned int) *(_str))
324 #define _strninc(_str, _inc) (((_str)+(_inc)))
325 #define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
326 #define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
328 #define _tchmod _chmod
329 #define _tcreat _creat
330 #define _tfindfirst _findfirst
331 #define _tfindnext _findnext
332 #define _tmktemp _mktemp
333 #define _topen _open
334 #define _taccess _access
335 #define _tremove remove
336 #define _trename rename
337 #define _tsopen _sopen
338 #define _tsetlocale setlocale
339 #define _tunlink _unlink
340 #define _tfinddata_t _finddata_t
343 #if 1 // defined __MSVCRT__
344 /* Not in crtdll.dll. Define macros anyway? */
345 #define _ttoi64 _atoi64
346 #define _i64tot _i64toa
347 #define _ui64tot _ui64toa
348 #define _tcsnccoll _strncoll
349 #define _tcsncoll _strncoll
350 #define _tcsncicoll _strnicoll
351 #define _tcsnicoll _strnicoll
352 #define _tfindfirsti64 _findfirsti64
353 #define _tfindnexti64 _findnexti64
354 #define _tfinddatai64_t _finddatai64_t
355 #endif /* __MSVCRT__ */
357 #endif /* Not _UNICODE */
360 * UNICODE a constant string when _UNICODE is defined else returns the string
361 * unmodified. Also defined in w32api/winnt.h.
363 #define _TEXT(x) __TEXT(x)
364 #define _T(x) __TEXT(x)
366 #endif /* Not _TCHAR_H_ */