1 /** 2 * @file tchar.h 3 * Copyright 2012, 2013 MinGW.org project 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 */ 24 #ifndef _TCHAR_H 25 #define _TCHAR_H 26 #pragma GCC system_header 27 #include <_mingw.h> 28 29 /* 30 * Unicode mapping layer for the standard C library. By including this 31 * file and using the 't' names for string functions 32 * (eg. _tprintf) you can make code which can be easily adapted to both 33 * Unicode and non-unicode environments. In a unicode enabled compile define 34 * _UNICODE before including tchar.h, otherwise the standard non-unicode 35 * library functions will be used. 36 * 37 * Note that you still need to include string.h or stdlib.h etc. to define 38 * the appropriate functions. Also note that there are several defines 39 * included for non-ANSI functions which are commonly available (but using 40 * the convention of prepending an underscore to non-ANSI library function 41 * names). 42 * 43 */ 44 45 /* 46 * NOTE: This tests _UNICODE, which is different from the UNICODE define 47 * used to differentiate Win32 API calls. 48 */ 49 #ifdef _UNICODE 50 51 /* 52 * Include <wchar.h> for wchar_t and WEOF if _UNICODE. 53 */ 54 #include <wchar.h> 55 56 /* 57 * Use TCHAR instead of char or wchar_t. It will be appropriately translated 58 * if _UNICODE is correctly defined (or not). 59 */ 60 #ifndef _TCHAR_DEFINED 61 #ifndef RC_INVOKED 62 typedef wchar_t TCHAR; 63 typedef wchar_t _TCHAR; 64 #endif /* ! RC_INVOKED */ 65 #define _TCHAR_DEFINED 66 #endif /* ! _TCHAR_DEFINED */ 67 68 /* 69 * Use _TEOF instead of EOF or WEOF. It will be appropriately translated if 70 * _UNICODE is correctly defined (or not). 71 */ 72 #define _TEOF WEOF 73 74 /* 75 * __TEXT is a private macro whose specific use is to force the expansion of a 76 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this 77 * macro within your programs. It's name and function could change without 78 * notice. 79 */ 80 #define __TEXT(q) L##q 81 82 /* for porting from other Windows compilers */ 83 #if 0 /* no wide startup module */ 84 #define _tmain wmain 85 #define _tWinMain wWinMain 86 #define _tenviron _wenviron 87 #define __targv __wargv 88 #endif 89 90 /* 91 * Unicode functions 92 */ 93 #define _tprintf wprintf 94 #define _ftprintf fwprintf 95 #define _stprintf swprintf 96 #define _sntprintf _snwprintf 97 #define _vtprintf vwprintf 98 #define _vftprintf vfwprintf 99 #define _vstprintf vswprintf 100 #define _vsntprintf _vsnwprintf 101 #define _vsctprintf _vscwprintf 102 #define _tscanf wscanf 103 #define _ftscanf fwscanf 104 #define _stscanf swscanf 105 #define _fgettc fgetwc 106 #define _fgettchar _fgetwchar 107 #define _fgetts fgetws 108 #define _fputtc fputwc 109 #define _fputtchar _fputwchar 110 #define _fputts fputws 111 #define _gettc getwc 112 #define _getts _getws 113 #define _puttc putwc 114 #define _puttchar putwchar 115 #define _putts _putws 116 #define _ungettc ungetwc 117 #define _tcstod wcstod 118 #define _tcstol wcstol 119 #define _tcstoul wcstoul 120 #define _itot _itow 121 #define _ltot _ltow 122 #define _ultot _ultow 123 #define _ttoi _wtoi 124 #define _ttol _wtol 125 #define _tcscat wcscat 126 #define _tcschr wcschr 127 #define _tcscmp wcscmp 128 #define _tcscpy wcscpy 129 #define _tcscspn wcscspn 130 #define _tcslen wcslen 131 #define _tcsclen wcslen 132 #define _tcsncat wcsncat 133 #define _tcsncmp wcsncmp 134 #define _tcsncpy wcsncpy 135 #define _tcspbrk wcspbrk 136 #define _tcsrchr wcsrchr 137 #define _tcsspn wcsspn 138 #define _tcsstr wcsstr 139 #define _tcstok wcstok 140 #define _tcsdup _wcsdup 141 #define _tcsicmp _wcsicmp 142 #define _tcsnicmp _wcsnicmp 143 #define _tcsnset _wcsnset 144 #define _tcsrev _wcsrev 145 #define _tcsset _wcsset 146 #define _tcslwr _wcslwr 147 #define _tcsupr _wcsupr 148 #define _tcsxfrm wcsxfrm 149 #define _tcscoll wcscoll 150 #define _tcsicoll _wcsicoll 151 #define _istalpha iswalpha 152 #define _istupper iswupper 153 #define _istlower iswlower 154 #define _istdigit iswdigit 155 #define _istxdigit iswxdigit 156 #define _istspace iswspace 157 #define _istpunct iswpunct 158 #define _istalnum iswalnum 159 #define _istprint iswprint 160 #define _istgraph iswgraph 161 #define _istcntrl iswcntrl 162 #define _istascii iswascii 163 #define _totupper towupper 164 #define _totlower towlower 165 #define _tcsftime wcsftime 166 /* Macro functions */ 167 #define _tcsdec _wcsdec 168 #define _tcsinc _wcsinc 169 #define _tcsnbcnt _wcsncnt 170 #define _tcsnccnt _wcsncnt 171 #define _tcsnextc _wcsnextc 172 #define _tcsninc _wcsninc 173 #define _tcsspnp _wcsspnp 174 #define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1) 175 #define _wcsinc(_wcs) ((_wcs)+1) 176 #define _wcsnextc(_wcs) ((unsigned int) *(_wcs)) 177 #define _wcsninc(_wcs, _inc) (((_wcs)+(_inc))) 178 #define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs)) 179 #define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL) 180 181 /* 182 * Define macros anyway so that _wfoo rather than _tfoo is undefined 183 */ 184 #define _ttoi64 _wtoi64 185 #define _i64tot _i64tow 186 #define _ui64tot _ui64tow 187 #define _tasctime _wasctime 188 #define _tctime _wctime 189 #define _tctime32 _wctime32 190 #define _tctime64 _wctime64 191 #define _tstrdate _wstrdate 192 #define _tstrtime _wstrtime 193 #define _tutime _wutime 194 #define _tutime64 _wutime64 195 #define _tutime32 _wutime32 196 #define _tcsnccoll _wcsncoll 197 #define _tcsncoll _wcsncoll 198 #define _tcsncicoll _wcsnicoll 199 #define _tcsnicoll _wcsnicoll 200 #define _taccess _waccess 201 #define _tchmod _wchmod 202 #define _tcreat _wcreat 203 #define _tfindfirst _wfindfirst 204 #define _tfindnext _wfindnext 205 #define _tfindfirst64 _wfindfirst64 206 #define _tfindfirst32 _wfindfirst32 207 #define _tfindnext64 _wfindnext64 208 #define _tfindnext32 _wfindnext32 209 #define _tfdopen _wfdopen 210 #define _tfopen _wfopen 211 #define _tfreopen _wfreopen 212 #define _tfsopen _wfsopen 213 #define _tgetenv _wgetenv 214 #define _tputenv _wputenv 215 #define _tsearchenv _wsearchenv 216 #define _tsystem _wsystem 217 #define _tmakepath _wmakepath 218 #define _tsplitpath _wsplitpath 219 #define _tfullpath _wfullpath 220 #define _tmktemp _wmktemp 221 #define _topen _wopen 222 #define _tremove _wremove 223 #define _trename _wrename 224 #define _tsopen _wsopen 225 #define _tsetlocale _wsetlocale 226 #define _tunlink _wunlink 227 #define _tfinddata_t _wfinddata_t 228 #define _tfindfirsti64 _wfindfirsti64 229 #define _tfindnexti64 _wfindnexti64 230 #define _tfinddatai64_t _wfinddatai64_t 231 #define _tfinddata64_t _wfinddata64_t 232 #define _tfinddata32_t _wfinddata32_t 233 #define _tfinddata32i64_t _wfinddata32i64_t 234 #define _tfinddata64i32_t _wfinddata64i32_t 235 #define _tfindfirst32i64 _wfindfirst32i64 236 #define _tfindfirst64i32 _wfindfirst64i32 237 #define _tfindnext32i64 _wfindnext32i64 238 #define _tfindnext64i32 _wfindnext64i32 239 #define _tchdir _wchdir 240 #define _tgetcwd _wgetcwd 241 #define _tgetdcwd _wgetdcwd 242 #define _tmkdir _wmkdir 243 #define _trmdir _wrmdir 244 #define _tstat _wstat 245 #define _tstati64 _wstati64 246 #define _tstat64 _wstat64 247 #define _tstat32 _wstat32 248 #define _tstat32i64 _wstat32i64 249 #define _tstat64i32 _wstat64i32 250 251 /* dirent structures and functions */ 252 #define _tdirent _wdirent 253 #define _TDIR _WDIR 254 #define _topendir _wopendir 255 #define _tclosedir _wclosedir 256 #define _treaddir _wreaddir 257 #define _trewinddir _wrewinddir 258 #define _ttelldir _wtelldir 259 #define _tseekdir _wseekdir 260 261 #else /* Not _UNICODE */ 262 263 /* 264 * TCHAR, the type you should use instead of char. 265 */ 266 #ifndef _TCHAR_DEFINED 267 #ifndef RC_INVOKED 268 typedef char TCHAR; 269 typedef char _TCHAR; 270 #endif /* ! RC_INVOKED */ 271 #define _TCHAR_DEFINED 272 #endif /* ! _TCHAR_DEFINED */ 273 274 /* 275 * _TEOF, the constant you should use instead of EOF. 276 */ 277 #define _TEOF EOF 278 279 /* 280 * __TEXT is a private macro whose specific use is to force the expansion of a 281 * macro passed as an argument to the macros _T or _TEXT. DO NOT use this 282 * macro within your programs. It's name and function could change without 283 * notice. 284 */ 285 #define __TEXT(q) q 286 287 /* for porting from other Windows compilers */ 288 #define _tmain main 289 #define _tWinMain WinMain 290 #define _tenviron _environ 291 #define __targv __argv 292 293 /* 294 * Non-unicode (standard) functions 295 */ 296 297 #define _tprintf printf 298 #define _ftprintf fprintf 299 #define _stprintf sprintf 300 #define _sntprintf _snprintf 301 #define _vtprintf vprintf 302 #define _vftprintf vfprintf 303 #define _vstprintf vsprintf 304 #define _vsntprintf _vsnprintf 305 #define _vsctprintf _vscprintf 306 #define _tscanf scanf 307 #define _ftscanf fscanf 308 #define _stscanf sscanf 309 #define _fgettc fgetc 310 #define _fgettchar _fgetchar 311 #define _fgetts fgets 312 #define _fputtc fputc 313 #define _fputtchar _fputchar 314 #define _fputts fputs 315 #define _tfdopen _fdopen 316 #define _tfopen fopen 317 #define _tfreopen freopen 318 #define _tfsopen _fsopen 319 #define _tgetenv getenv 320 #define _tputenv _putenv 321 #define _tsearchenv _searchenv 322 #define _tsystem system 323 #define _tmakepath _makepath 324 #define _tsplitpath _splitpath 325 #define _tfullpath _fullpath 326 #define _gettc getc 327 #define _getts gets 328 #define _puttc putc 329 #define _puttchar putchar 330 #define _putts puts 331 #define _ungettc ungetc 332 #define _tcstod strtod 333 #define _tcstol strtol 334 #define _tcstoul strtoul 335 #define _itot _itoa 336 #define _ltot _ltoa 337 #define _ultot _ultoa 338 #define _ttoi atoi 339 #define _ttol atol 340 #define _tcscat strcat 341 #define _tcschr strchr 342 #define _tcscmp strcmp 343 #define _tcscpy strcpy 344 #define _tcscspn strcspn 345 #define _tcslen strlen 346 #define _tcsclen strlen 347 #define _tcsncat strncat 348 #define _tcsncmp strncmp 349 #define _tcsncpy strncpy 350 #define _tcspbrk strpbrk 351 #define _tcsrchr strrchr 352 #define _tcsspn strspn 353 #define _tcsstr strstr 354 #define _tcstok strtok 355 #define _tcsdup _strdup 356 #define _tcsicmp _stricmp 357 #define _tcsnicmp _strnicmp 358 #define _tcsnset _strnset 359 #define _tcsrev _strrev 360 #define _tcsset _strset 361 #define _tcslwr _strlwr 362 #define _tcsupr _strupr 363 #define _tcsxfrm strxfrm 364 #define _tcscoll strcoll 365 #define _tcsicoll _stricoll 366 #define _istalpha isalpha 367 #define _istupper isupper 368 #define _istlower islower 369 #define _istdigit isdigit 370 #define _istxdigit isxdigit 371 #define _istspace isspace 372 #define _istpunct ispunct 373 #define _istalnum isalnum 374 #define _istprint isprint 375 #define _istgraph isgraph 376 #define _istcntrl iscntrl 377 #define _istascii isascii 378 #define _totupper toupper 379 #define _totlower tolower 380 #define _tasctime asctime 381 #define _tctime ctime 382 #define _tctime32 _ctime32 383 #define _tctime64 _ctime64 384 #define _tstrdate _strdate 385 #define _tstrtime _strtime 386 #define _tutime _utime 387 #define _tutime64 _utime64 388 #define _tutime32 _utime32 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) 404 405 #define _tchmod _chmod 406 #define _tcreat _creat 407 #define _tfindfirst _findfirst 408 #define _tfindnext _findnext 409 #define _tfindfirst64 _findfirst64 410 #define _tfindfirst32 _findfirst32 411 #define _tfindnext64 _findnext64 412 #define _tfindnext32 _findnext32 413 #define _tmktemp _mktemp 414 #define _topen _open 415 #define _taccess _access 416 #define _tremove remove 417 #define _trename rename 418 #define _tsopen _sopen 419 #define _tsetlocale setlocale 420 #define _tunlink _unlink 421 #define _tfinddata_t _finddata_t 422 #define _tchdir _chdir 423 #define _tgetcwd _getcwd 424 #define _tgetdcwd _getdcwd 425 #define _tmkdir _mkdir 426 #define _trmdir _rmdir 427 #define _tstat _stat 428 429 #define _ttoi64 _atoi64 430 #define _i64tot _i64toa 431 #define _ui64tot _ui64toa 432 #define _tcsnccoll _strncoll 433 #define _tcsncoll _strncoll 434 #define _tcsncicoll _strnicoll 435 #define _tcsnicoll _strnicoll 436 #define _tfindfirsti64 _findfirsti64 437 #define _tfindnexti64 _findnexti64 438 #define _tfinddatai64_t _finddatai64_t 439 #define _tfinddata64_t _finddata64_t 440 #define _tfinddata32_t _finddata32_t 441 #define _tfinddata32i64_t _finddata32i64_t 442 #define _tfinddata64i32_t _finddata64i32_t 443 #define _tfindfirst32i64 _findfirst32i64 444 #define _tfindfirst64i32 _findfirst64i32 445 #define _tfindnext32i64 _findnext32i64 446 #define _tfindnext64i32 _findnext64i32 447 #define _tstati64 _stati64 448 #define _tstat64 _stat64 449 #define _tstat32 _stat32 450 #define _tstat32i64 _stat32i64 451 #define _tstat64i32 _stat64i32 452 453 /* dirent structures and functions */ 454 #define _tdirent dirent 455 #define _TDIR DIR 456 #define _topendir opendir 457 #define _tclosedir closedir 458 #define _treaddir readdir 459 #define _trewinddir rewinddir 460 #define _ttelldir telldir 461 #define _tseekdir seekdir 462 463 #endif /* ! _UNICODE */ 464 465 /* 466 * UNICODE a constant string when _UNICODE is defined else returns the string 467 * unmodified. Also defined in w32api/winnt.h. 468 */ 469 #define _TEXT(x) __TEXT(x) 470 #define _T(x) __TEXT(x) 471 472 #endif /* ! _TCHAR_H */ 473