UCRT's struct _iobuf is slightly different than the msvcrt struct _iobuf.
It swapped order of _base and _cnt members plus has additional _lock
member. And member _flag was renamed to _flags. In public header was member
_ptr renamed to _Placeholder.
To make the struct _iobuf compatible _at source level_, declare the renamed
members in union to allow accessing members under both old and new names.
---
mingw-w64-headers/crt/mbstring.h | 26 ++++++++++++++++++++++++--
mingw-w64-headers/crt/stdio.h | 24 +++++++++++++++++++++---
mingw-w64-headers/crt/wchar.h | 26 ++++++++++++++++++++++++--
3 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/mingw-w64-headers/crt/mbstring.h b/mingw-w64-headers/crt/mbstring.h
index e9e43a13a1e1..6e393f08c36a 100644
--- a/mingw-w64-headers/crt/mbstring.h
+++ b/mingw-w64-headers/crt/mbstring.h
@@ -16,14 +16,36 @@ extern "C" {
#ifndef _FILE_DEFINED
struct _iobuf {
- char *_ptr;
+ union {
+ void *_Placeholder; /* UCRT name in public header */
+ char *_ptr; /* msvcrt name and UCRT name in private header */
+ };
+#ifdef _UCRT
+ char *_base;
+ int _cnt;
+#else
int _cnt;
char *_base;
- int _flag;
+#endif
+ union {
+ int _flags; /* UCRT name */
+ int _flag; /* msvcrt name */
+ };
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
+#ifdef _UCRT
+ #ifdef _WINDOWS_
+ CRITICAL_SECTION _lock;
+ #else /* building without windows.h */
+ #ifdef _WIN64
+ struct { char data[24]; } _lock; /* placeholder with same size as 64-bit
CRITICAL_SECTION */
+ #else
+ struct { char data[40]; } _lock; /* placeholder with same size as 32-bit
CRITICAL_SECTION */
+ #endif
+ #endif
+#endif
};
typedef struct _iobuf FILE;
#define _FILE_DEFINED
diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index 721b68463351..1d9603b81d48 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -31,17 +31,35 @@ extern "C" {
#ifndef _FILE_DEFINED
struct _iobuf {
+ union {
+ void *_Placeholder; /* UCRT name in public header */
+ char *_ptr; /* msvcrt name and UCRT name in private header */
+ };
#ifdef _UCRT
- void *_Placeholder;
+ char *_base;
+ int _cnt;
#else
- char *_ptr;
int _cnt;
char *_base;
- int _flag;
+#endif
+ union {
+ int _flags; /* UCRT name */
+ int _flag; /* msvcrt name */
+ };
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
+#ifdef _UCRT
+ #ifdef _WINDOWS_
+ CRITICAL_SECTION _lock;
+ #else /* building without windows.h */
+ #ifdef _WIN64
+ struct { char data[24]; } _lock; /* placeholder with same size as 64-bit
CRITICAL_SECTION */
+ #else
+ struct { char data[40]; } _lock; /* placeholder with same size as 32-bit
CRITICAL_SECTION */
+ #endif
+ #endif
#endif
};
typedef struct _iobuf FILE;
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index 898d0e821b76..4ad17b44cffb 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -41,14 +41,36 @@ extern "C" {
#ifndef _FILE_DEFINED
struct _iobuf {
- char *_ptr;
+ union {
+ void *_Placeholder; /* UCRT name in public header */
+ char *_ptr; /* msvcrt name and UCRT name in private header */
+ };
+#ifdef _UCRT
+ char *_base;
+ int _cnt;
+#else
int _cnt;
char *_base;
- int _flag;
+#endif
+ union {
+ int _flags; /* UCRT name */
+ int _flag; /* msvcrt name */
+ };
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
+#ifdef _UCRT
+ #ifdef _WINDOWS_
+ CRITICAL_SECTION _lock;
+ #else /* building without windows.h */
+ #ifdef _WIN64
+ struct { char data[24]; } _lock; /* placeholder with same size as 64-bit
CRITICAL_SECTION */
+ #else
+ struct { char data[40]; } _lock; /* placeholder with same size as 32-bit
CRITICAL_SECTION */
+ #endif
+ #endif
+#endif
};
typedef struct _iobuf FILE;
#define _FILE_DEFINED
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public