Am 04.01.19 um 15:08 schrieb Liu Hao:
在 2019/1/4 21:14, Johannes Pfau 写道:

When building GCC against msvcr120, I found another problem. The build
fails here:

(... snip ...)

This prints 0 with msvcrt, -1 with msvcr120 (tested using a spec file &
setting -D__MSVCRT_VERSION__=0x1200). GCC uses this function to check if
an input file exists and therefore the check for the special 'nul' file
is bugged with msvcr120. I've send a RFC to the gcc-patches list with a
patch to use GetFileAttributes on windows instead, but I've been told to
first ask here for advice.


This is caused by the fact that `_access_s()` in MSVCRT calls
`GetFileAttributesW()` which returns attribute `0x20` for DOS device
filenames such as `nul`, `con`, `com1`, etc, while the one in newer
MSVCR* calls `GetFileAttributesExW()` which returns an error.

To observer the difference, compile and run the program attached here.

Use of `GetFileAttributesA()` should be capable of fixing this problem.
Note that your patch on
<https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00090.html> has to call
the explicit A variant because the argument is of pointer to `char`
rather than to `TCHAR`.

I see. Thanks for the hint to use GetFileAttributesA instead of GetFileAttributes. To summarize, you think this is something that should be fixed in GCC by explicitly using GetFileAttributesA instead of using the access function?

Best regards,

Johannes



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to