On Sat, 7 Dec 2024, Kirill Makurin wrote:
Hi,
io.h provided by mingw-w64 defines *_OK macros for use with _access/access
function. However, X_OK has value of 1 and documentation for _access does not
list this value as supported.
(https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess)
Every call to
```
_access(filename, X_OK)
```
will always return -1 and set errno to EINVAL.
Windows does not use execution permissions for files. Maybe it would
make sense to define X_OK to the same value as R_OK?
This issue has been popping up on and off in various incarnations
throughout the years; GCC were affected by this around the time of Vista,
but a workaround was added, where GCC defined -D__USE_MINGW_ACCESS, which
does "#define access(__f,__m) __mingw_access (__f, __m)", which points to
a different reimplementation of access() where this works.
Then across updates of GCC, the define of -D__USE_MINGW_ACCESS didn't get
applied everywhere, but efforts were made to add it where needed.
In any case, it seems like the issue with X_OK in access() in msvcrt.dll
doesn't appear everywhere though - but it does appear with UCRT at least.
In bceadc54d8f32b3f14c69074892e2718eac08e3b we permanently redirected
access() to __mingw_access() for UCRT configurations.
With what CRT do you run into the issue, and on what OS?
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public