These two files dirent.c and ftw.c are using the mingw-w64 dirent.h header file which has unsable / broken ABI. Structures in this header file depends on application defines which are unknown at mingw-w64 crt compile time. Define *find* macro redirects to default symbols used by the msvc import libs to allow compiling these files.
This change does not fix the ABI issue with dirent.h header file and dirent.c and ftw.c crt files. It just hides the issue to allow dirent.c and ftw.c to be compiled. The proper way to define define ftw.c / dirent.c symbols for each variant and then from dirent.h header file redirect to the correct symbol based on the application defines. This issue was uncovered by the previous change: headers: Guard _(w)findfirst(i64)/_(w)findnext(i64) functions for CRT build --- mingw-w64-crt/misc/dirent.c | 23 +++++++++++++++++++++++ mingw-w64-crt/misc/ftw.c | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/mingw-w64-crt/misc/dirent.c b/mingw-w64-crt/misc/dirent.c index 4897cf492fa1..66aa34730d49 100644 --- a/mingw-w64-crt/misc/dirent.c +++ b/mingw-w64-crt/misc/dirent.c @@ -14,6 +14,29 @@ * */ +/* mingw-w64 <dirent.h> header file is ABI broken. Its structures depends + * on application defines which are unknown at mingw-w64 crt compile time. + * That header file should be fixed to use only fixed-size symbols and + * structures. Until that happen, define here macros redirects to default + * symbols used by the msvc import libs. Without redirects, this file + * cannot be compiled. + */ +#ifdef _WIN64 +#define _finddata_t _finddata64i32_t +#define _findfirst _findfirst64i32 +#define _findnext _findnext64i32 +#define _wfinddata_t _wfinddata64i32_t +#define _wfindfirst _wfindfirst64i32 +#define _wfindnext _wfindnext64i32 +#else +#define _finddata_t _finddata32_t +#define _findfirst _findfirst32 +#define _findnext _findnext32 +#define _wfinddata_t _wfinddata32_t +#define _wfindfirst _wfindfirst32 +#define _wfindnext _wfindnext32 +#endif + #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif diff --git a/mingw-w64-crt/misc/ftw.c b/mingw-w64-crt/misc/ftw.c index f520ef63da78..cdd6c4def5e4 100644 --- a/mingw-w64-crt/misc/ftw.c +++ b/mingw-w64-crt/misc/ftw.c @@ -3,6 +3,29 @@ * No warranty is given; refer to the file DISCLAIMER within this package. */ +/* mingw-w64 <dirent.h> header file is ABI broken. Its structures depends + * on application defines which are unknown at mingw-w64 crt compile time. + * That header file should be fixed to use only fixed-size symbols and + * structures. Until that happen, define here macros redirects to default + * symbols used by the msvc import libs. Without redirects, this file + * cannot be compiled. + */ +#ifdef _WIN64 +#define _finddata_t _finddata64i32_t +#define _findfirst _findfirst64i32 +#define _findnext _findnext64i32 +#define _wfinddata_t _wfinddata64i32_t +#define _wfindfirst _wfindfirst64i32 +#define _wfindnext _wfindnext64i32 +#else +#define _finddata_t _finddata32_t +#define _findfirst _findfirst32 +#define _findnext _findnext32 +#define _wfinddata_t _wfinddata32_t +#define _wfindfirst _wfindfirst32 +#define _wfindnext _wfindnext32 +#endif + #include <stdlib.h> #include <unistd.h> #include <malloc.h> -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
