[PATCH v2 2/4] include: only define _tcs macros on suitable libc.
Kevin Puetz
PuetzKevinA at JohnDeere.com
Thu Sep 17 17:49:03 CDT 2020
When winegcc is using an underlying POSIX libc (rather than -mno-cygwin)
it will only have `char` and `wchar_t` functions. If _TCHAR is neither
of these there may be no suitable function to alias _tcs* to.
Signed-off-by: Kevin Puetz <PuetzKevinA at JohnDeere.com>
---
wine-5.2 (c12089039637dec5e598ed1c41e707f057494242) allowed <tchar.h>
to be used without MSVCRT. _TEXT(...) and _TCHAR typedef are useful,
but the _tcs* macros may still be unusable.
Omitting them will be a clearer compile error when to not exist
than mapping them to e.g. wcs* functions which do not accept
a windows WCHAR (!= wchar_t),
---
include/tchar.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/tchar.h b/include/tchar.h
index e1e21df272..5eb8972563 100644
--- a/include/tchar.h
+++ b/include/tchar.h
@@ -37,9 +37,15 @@ extern "C" {
#define _strninc(str,n) (((char*)(str))+(n))
#define _strspnp(s1,s2) (*((s1)+=strspn((s1),(s2))) ? (s1) : NULL)
+#if defined(__MSVCRT__) || defined(_MSC_VER) || (defined(WINE_UNICODE_NATIVE) && defined(_UNICODE)) || !(defined(_UNICODE) || defined(_MBCS))
/*****************************************************************************
* tchar mappings
+ *
+ * These can only be defined when libc in use will have functions accepting _TCHAR, i.e.
+ * -mno-cygwin / __MSVCRT__ or __MSC_VER
+ * -fshort-wchar / WINE_UNICODE_NATIVE and _UNICODE (_TCHAR == WCHAR == wchar_t, so the libc wcs* functions are UTF-16)
+ * _TCHAR == `char` without _MBCS
*/
#ifndef _UNICODE
# ifndef _MBCS
@@ -223,6 +229,8 @@ extern "C" {
#define _vtprintf WINE_tchar_routine(vprintf, vprintf, vwprintf)
#define _TEOF WINE_tchar_routine(EOF, EOF, WEOF)
+#endif /* tchar mappings */
+
#define __T(x) __TEXT(x)
#define _T(x) __T(x)
#define _TEXT(x) __T(x)
More information about the wine-devel
mailing list