Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Declare getopt function on older GNU libc #73

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion include/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ struct option
declaration without arguments. If it is 0, we checked and failed
to find the declaration so provide a fully prototyped one. If it
is 1, we found it so don't provide any declaration at all. */
#if !HAVE_DECL_GETOPT
/* On GNU libc <= 2,25, <unistd.h> includes <getopt.h> with __need_getopt
macro defined. That <getopt.h> is intended to be a part of GNU libc
but <unistd.h> actually includes THIS getopt.h. If HAVE_DECL_GETOPT is
defined to 1 and this file is included from GNU libc's <unistd.h>,
declaration of getopt is suppressed, causing errors on getopt callers.
To avoid not defining proper getopt declaration, we have to check
__need_getopt macro when built with GNU libc to detect this include path. */
#if !HAVE_DECL_GETOPT || (defined (__GNU_LIBRARY__) && defined (__need_getopt))
#if defined (__GNU_LIBRARY__) || defined (HAVE_DECL_GETOPT)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in unistd.h. To avoid compilation
Expand Down