Discussion:
Problem compiling glob.c with MinGW
Eli Zaretskii
2018-05-12 15:20:42 UTC
Permalink
Date: Sat, 12 May 2018 17:13:21 +0200
Would it be okay to use 'unsigned' instead of 'uint8_t' on all
platforms?
Thank you.
Eli Zaretskii
2018-05-12 13:02:41 UTC
Permalink
Date: Sat, 12 May 2018 14:18:36 +0200
CC glob.lo
glob.c:1331:32: warning: case label value exceeds maximum value for type
case DT_DIR: case DT_LNK: case DT_UNKNOWN: break;
^~~~
This is because glob.c unconditionally defines dirent_type data
typedef uint_fast8_t dirent_type;
But if system header dirent.h is found to define the d_type member of
struct dirent, the type should be the same as for d_type, or at least
as wide as that of d_type, otherwise the DT_* constants, which come
from dirent.h, might be outside the valid range of values for unsigned
char.
The comments in https://sourceforge.net/p/mingw/mingw-org-wsl/ci/5.1-trunk/tree/mingwrt/include/dirent.h#l137
say that these d_type values >= 0x100 "will never" be assigned by
the opendir()/readdir() implementation. So, since these values actually
never occur, the warning is harmless.
"Never" is a very long time. Windows does support links, and someone
might actually make readdir return that value.

So I think it would be better to avoid the warning.

Loading...