During discussion about inttypes I realized that we check (in header files) if __USE_MINGW_ANSI_STDIO is active in non consistent way: #if defined(__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) #elif defined(__USE_MINGW_ANSI_STDIO) #if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0
Attached patch simplified checking if __USE_MINGW_ANSI_STDIO is active -- it always define __USE_MINGW_ANSI_STDIO to 0 or 1 in _mingw.h so now it should be simple: #if __USE_MINGW_ANSI_STDIO /* active */ #if __USE_MINGW_ANSI_STDIO == 0 /* not active */ Please review. Regards, Mateusz
From fdd383cbb0e636c609c19f78f1c0655d94f0c4e5 Mon Sep 17 00:00:00 2001 From: Mateusz <mateu...@poczta.onet.pl> Date: Thu, 1 Nov 2018 01:07:37 +0100 Subject: [PATCH] Always define __USE_MINGW_ANSI_STDIO as 0 or 1 in _mingw.h We check state of __USE_MINGW_ANSI_STDIO in many places. This patch checks all corner cases for __USE_MINGW_ANSI_STDIO in one place in _mingw.h and then we have easy and consistent check -- it is 0 or 1. Signed-off-by: Mateusz Brzostek <mateu...@poczta.onet.pl> --- mingw-w64-headers/crt/_mingw.h.in | 9 +++++++++ mingw-w64-headers/crt/_mingw_print_pop.h | 4 ++-- mingw-w64-headers/crt/_mingw_print_push.h | 4 ++-- mingw-w64-headers/crt/stdio.h | 8 ++++---- mingw-w64-headers/crt/stdlib.h | 2 +- mingw-w64-headers/crt/wchar.h | 6 +++--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/mingw-w64-headers/crt/_mingw.h.in b/mingw-w64-headers/crt/_mingw.h.in index bbbd07d0..c6b9d760 100644 --- a/mingw-w64-headers/crt/_mingw.h.in +++ b/mingw-w64-headers/crt/_mingw.h.in @@ -428,6 +428,15 @@ typedef int __int128 __attribute__ ((__mode__ (TI))); # define __USE_MINGW_ANSI_STDIO 1 #endif +/* We are defining __USE_MINGW_ANSI_STDIO as 0 or 1 */ +#if !defined(__USE_MINGW_ANSI_STDIO) +#define __USE_MINGW_ANSI_STDIO 0 /* was not defined so it should be 0 */ +#elif (__USE_MINGW_ANSI_STDIO + 0) != 0 || (1 - __USE_MINGW_ANSI_STDIO - 1) == 2 +#define __USE_MINGW_ANSI_STDIO 1 /* was defined as nonzero or empty so it should be 1 */ +#else +#define __USE_MINGW_ANSI_STDIO 0 /* was defined as (int)zero and non-empty so it should be 0 */ +#endif + /* _dowildcard is an int that controls the globbing of the command line. * The MinGW32 (mingw.org) runtime calls it _CRT_glob, so we are adding * a compatibility definition here: you can use either of _CRT_glob or diff --git a/mingw-w64-headers/crt/_mingw_print_pop.h b/mingw-w64-headers/crt/_mingw_print_pop.h index 046b6203..491749ea 100644 --- a/mingw-w64-headers/crt/_mingw_print_pop.h +++ b/mingw-w64-headers/crt/_mingw_print_pop.h @@ -5,7 +5,7 @@ */ /* Define __mingw_<printf> macros. */ -#if defined(__USE_MINGW_ANSI_STDIO) && (defined(_INC_STDIO) || defined(_WSTDIO_DEFINED)) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) +#if __USE_MINGW_ANSI_STDIO && (defined(_INC_STDIO) || defined(_WSTDIO_DEFINED)) /* Redefine to GNU specific PRI... and SCN... macros. */ #if defined(_INTTYPES_H_) && defined(PRId64) @@ -133,4 +133,4 @@ #endif /* _WIN64 */ #endif /* defined(_INTTYPES_H_) && defined(PRId64) */ -#endif /* defined(__USE_MINGW_ANSI_STDIO) && defined(_INC_STDIO) && __USE_MINGW_ANSI_STDIO != 0 */ +#endif /* __USE_MINGW_ANSI_STDIO && defined(_INC_STDIO) */ diff --git a/mingw-w64-headers/crt/_mingw_print_push.h b/mingw-w64-headers/crt/_mingw_print_push.h index e0da9d00..eca11bf9 100644 --- a/mingw-w64-headers/crt/_mingw_print_push.h +++ b/mingw-w64-headers/crt/_mingw_print_push.h @@ -5,7 +5,7 @@ */ /* Undefine __mingw_<printf> macros. */ -#if defined(__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) +#if __USE_MINGW_ANSI_STDIO /* Redefine to MS specific PRI... and SCN... macros. */ #if defined(_INTTYPES_H_) && defined(PRId64) @@ -133,4 +133,4 @@ #endif /* defined(_INTTYPES_H_) && defined(PRId64) */ -#endif /* defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO != 0 */ +#endif /* __USE_MINGW_ANSI_STDIO */ diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index d981f701..a7f0ae8c 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -223,7 +223,7 @@ extern #if defined(__clang__) #define __MINGW_PRINTF_FORMAT printf #define __MINGW_SCANF_FORMAT scanf -#elif defined(__USE_MINGW_ANSI_STDIO) +#elif __USE_MINGW_ANSI_STDIO #define __MINGW_PRINTF_FORMAT gnu_printf #define __MINGW_SCANF_FORMAT gnu_scanf #else @@ -737,7 +737,7 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li _CRTIMP int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; #endif -#if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0 +#if __USE_MINGW_ANSI_STDIO == 0 #if __MSVCRT_VERSION__ >= 0x1400 #ifdef __GNUC__ @@ -1142,7 +1142,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti } int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; -#if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0 +#if __USE_MINGW_ANSI_STDIO == 0 __mingw_ovr int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...) { @@ -1192,7 +1192,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti #ifndef __NO_ISOCEXT /* externs in libmingwex.a */ -#if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0 +#if __USE_MINGW_ANSI_STDIO == 0 #pragma push_macro("snwprintf") #pragma push_macro("vsnwprintf") # undef snwprintf diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h index 4d9c1d96..22b53b90 100644 --- a/mingw-w64-headers/crt/stdlib.h +++ b/mingw-w64-headers/crt/stdlib.h @@ -9,7 +9,7 @@ #include <crtdefs.h> #include <limits.h> -#if defined (__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) && !defined (__USE_MINGW_STRTOX) +#if __USE_MINGW_ANSI_STDIO && !defined (__USE_MINGW_STRTOX) #define __USE_MINGW_STRTOX 1 #endif diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index ce041ade..2b02d82a 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h @@ -9,7 +9,7 @@ #include <crtdefs.h> #include <_mingw_print_push.h> -#if defined (__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) && !defined (__USE_MINGW_STRTOX) +#if __USE_MINGW_ANSI_STDIO && !defined (__USE_MINGW_STRTOX) #define __USE_MINGW_STRTOX 1 #endif @@ -809,7 +809,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti return __stdio_common_vswprintf(UCRTBASE_PRINTF_DEFAULT_WIDE | UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args); } -#if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0 +#if __USE_MINGW_ANSI_STDIO == 0 __mingw_ovr int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...) { @@ -837,7 +837,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti #ifndef __NO_ISOCEXT /* externs in libmingwex.a */ -#if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0 +#if __USE_MINGW_ANSI_STDIO == 0 #pragma push_macro("snwprintf") #pragma push_macro("vsnwprintf") # undef snwprintf -- 2.19.1.windows.1
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public