According to this, the POSIX library does not include getopt.h
. However, I found this in unistd.h
:
#ifdef __USE_POSIX2
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS. */
# define __need_getopt
# include <getopt.h>
#endif
Does this mean that getopt.h
is implicitly included when you include unistd.h
? I mean, is the code above something I should expect from all implementations of the unistd header file, or is it just something that is in my particular version? Also, is the __USE_POSIX2
macro defined in POSIX.2 and onwards, or is it just for POSIX.2?