[PATCH 5/5] include: Fix conflicting definitions of NULL, wchar_t, wint_t, wctype_t.
jacek at codeweavers.com
Wed Jul 22 07:35:15 CDT 2020
On 17.07.2020 03:12, Puetz Kevin A wrote:
> When <basetyps.h> defines wchar_t, it must obey -f(no-)short-wchar
> by referring to __WCHAR_TYPE__ which may not be `unsigned short`.
> Similarly, windef.h defining NULL may need to use GCC's __null.
> Otherwise one-definition-rule problems arise depending on whether
> wine or libc headers are included first.
> Implementing these by deferring to the C89-specified libc headers,
> (or msvcrt's versions with -mno-cygwin) ensures matching definitions.
This seems to be indeed the most compatible way. It looks like __need_*
macros widely supported (not only by GCC itself, but also versions
provided by mingw and LLVM). We may want to support that in our msvcrt
headers, if we start using it.
However, it's not supported by MSVC. The fallback should still work, as
you explained, but I wonder if it would be safer to guard stddef.h usage
by defined(__GNUC__) and leave existing definitions for other
> Signed-off-by: Kevin Puetz <PuetzKevinA at JohnDeere.com>
> include/basetyps.h | 8 +++++---
> include/tchar.h | 9 +--------
> include/windef.h | 11 +++++++----
> 3 files changed, 13 insertions(+), 15 deletions(-)
> diff --git a/include/basetyps.h b/include/basetyps.h
> index b0dd5d77f4..e6243d5a59 100644
> --- a/include/basetyps.h
> +++ b/include/basetyps.h
> @@ -91,9 +91,11 @@ typedef unsigned long error_status_t;
> #ifndef _WCHAR_T_DEFINED
> -#ifndef __cplusplus
> -typedef unsigned short wchar_t;
> +# ifndef __cplusplus
> +# define __need_wchar_t // tells GCC's stddef.h to only define wchar_t
Please avoid C++ style comments. Wine uses /* */ comments.
More information about the wine-devel