| dce0da61 | 26-Dec-2021 |
Pali Rohár <[email protected]> |
compat/getopt: Fix compatibility with non-GNU C library
Remove "#if defined(__GNU_LIBRARY__)" guard for getopt() function prototype in compat/getopt.h header file. The only purpose of compat/getopt.
compat/getopt: Fix compatibility with non-GNU C library
Remove "#if defined(__GNU_LIBRARY__)" guard for getopt() function prototype in compat/getopt.h header file. The only purpose of compat/getopt.h header is to provide getopt() function prototype for compatibility purpose on every platform, specially those which do not use GNU C library (e.g. Windows).
Without this change i586-mingw32msvc-gcc compiler complains that function getopt() is used without defined prototype.
Also remove inclusion of #include <string.h> header file in compat/getopt.c source file. Probably due to compatibility purposes compat/getopt.c file has defined custom prototype for function strncmp() incompatible with C99 (length argument in C99 should be of type size_t). Including C99 prototype of strncmp() function from MinGW32 <string.h> header file cause compile errors for i586-mingw32msvc-gcc compiler. Instead of including <stringh> provides custom and simple my_strncmp() implementation.
Thsi change fixes compilation of compat/getopt.c with i586-mingw32msvc-gcc, i686-w64-mingw32-gcc, x86_64-w64-mingw32-gcc and also MSVC cl compilers.
show more ...
|