]> mj.ucw.cz Git - pciutils.git/commit
compat/getopt: Fix compatibility with non-GNU C library
authorPali Rohár <pali@kernel.org>
Sun, 26 Dec 2021 17:19:25 +0000 (18:19 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 28 Dec 2021 15:26:39 +0000 (16:26 +0100)
commitdce0da6171f039d151f7a85db5a44ed57e20fcdf
treeae79edda4213d071bda0889df7561880e5b1bdc8
parent4658bfad1878c47e2cb6a42ec5dbd9b0ad6739dd
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.
compat/getopt.c
compat/getopt.h