David Gressett
DGres****@amli-*****
Wed Jun 27 09:06:17 JST 2018
I have been trying to build gcc 7.3.0 as a native build using the current MinGW gcc compiler, which is at version 6.3.0. My buillds are crashing early in the build process when it reaches a file named adaint.c Adaint.c caused no problems with my earlier gcc 6.3.0 and 7.1.0 builds, but with 7.3.0, I was getting a swarm of error message from the adaint.c compilation. The first one looked like this: error: cannot convert 'TCHAR* {aka wchar_t*}' to 'LPCSTR {aka const char*}' for argument '1' to 'BOOL GetFileAttributesExA(LPCSTR, GET_FILEEX_INFO_LEVELS, PVOID)' I extracted adaint.c and several header files that it included and proceeded to strip them down to a minimal test case. The result was a set of three files, adaint.c, adaint.h, and mingw32.h, which are now only a tiny fraction of their original sizes; I can open all three of them in a text editor on my dual-monitor development computer and see all of the contents of all three of them. The shrunken version produces an error, but it changed. If I issue the command gcc -c adaint.c , I get this error text with the current gcc: ( long lines have been broken) adaint.c: In function '__gnat_file_time_name_attr': adaint.c:21:39: warning: passing argument 1 of 'GetFileAttributesExA' from incompatible pointer type [-Wincompatible-pointer-types] if ((res = GetFileAttributesEx (wname, GetFileExInfoStandard, &fad))) ^~~~~ In file included from c:\mingw\include\windows.h:44:0, from mingw32.h:14, from adaint.c:5: c:\mingw\include\winbase.h:1728:24: note: expected 'LPCSTR {aka const char *}' but argument is of type 'TCHAR * {aka short unsigned int *}' WINBASEAPI BOOL WINAPI GetFileAttributesExA When I did my earlier successful builds of gcc 6.3.0, 7.1.0, and my experimental gcc 7.1.0 with sjlj exceptions, I installed them into my MinGW direcrory and backed them up so that I could recover them later. I did that, and tested them on test case. All three of them compiled the test case with no errors, so it looks like a problem with something that changed since I made those builds, possibly problem in the current WSL 5.0.2. (I haven't tried the WSL 5.1 that is currently up on OSDN) Here are the three pieces of the test case. Long lines are not broken. I'm hoping that Microsoft Outlook won't scramble them. Here is the first one: adaint.c, 26 lines of text: #ifdef __cplusplus extern "C" { #endif #include "mingw32.h" #include "adaint.h" #define GNAT_MAX_PATH_LEN 256 OS_Time __gnat_file_time_name_attr (char* name, struct file_attributes* attr) { if (attr->timestamp == (OS_Time)-2) { BOOL res; WIN32_FILE_ATTRIBUTE_DATA fad; GNAT_TIME_T ret = -1; TCHAR wname[GNAT_MAX_PATH_LEN]; S2WSC (wname, name, GNAT_MAX_PATH_LEN); if ((res = GetFileAttributesEx (wname, GetFileExInfoStandard, &fad))) /* f2t (&fad.ftLastWriteTime, &ret) */; attr->timestamp = (OS_Time) ret; } return attr->timestamp; } The next one is adaint.h, 36 lines of text : #ifdef __cplusplus extern "C" { #endif #include "mingw32.h" #define GNAT_STRUCT_STAT struct _stati64 #define GNAT_TIME_T time_t typedef long OS_Time; #define __int64 long long GNAT_STRUCT_STAT; struct file_attributes { int error; unsigned char exists; unsigned char writable; unsigned char readable; unsigned char executable; unsigned char symbolic_link; unsigned char regular; unsigned char directory; OS_Time timestamp; __int64 file_length; }; extern OS_Time __gnat_file_time_name_attr (char *, struct file_attributes *); #ifdef __cplusplus } #endif Here is the last one, mingw32.h, 27 lines of text: #ifndef _MINGW32_H #define _MINGW32_H #include <_mingw.h> #ifndef RTX #define GNAT_UNICODE_SUPPORT #define _UNICODE /* For C runtime */ #define UNICODE /* For Win32 API */ #endif #include <tchar.h> #include <windows.h> #ifdef GNAT_UNICODE_SUPPORT extern UINT __gnat_current_codepage; extern UINT __gnat_current_ccs_encoding; #define S2WSC(wstr,str,len) \ MultiByteToWideChar (__gnat_current_codepage,0,str,-1,wstr,len) #else #define S2WSC(wstr,str,len) strncpy(wstr,str,len) #endif #include <stdlib.h> #endif /* _MINGW32_H */