#include <getopt.h>
getopt.h
$NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $
macrono_argument
GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
getopt() is declared here too for GNU programs.
#define no_argument 0
macrorequired_argument
#define required_argument 1
macrooptional_argument
#define optional_argument 2
structoption
| const char * | name | name of long option |
| int | has_arg | one of no_argument, required_argument, and optional_argument: whether option takes an argument |
| int * | flag | if not NULL, set *flag to val when option found |
| int | val | if flag not NULL, value to set *flag to; else return value |
functiongetopt_long
int getopt_long( int __argc, char *_LIBC_CSTR const *_LIBC_COUNT(__argc), const char *, const struct option *, int * )
man page · December 24, 2022
getopt_long(3) — get long options from command line argument listfunctiongetopt_long_only
int getopt_long_only( int __argc, char * const *_LIBC_COUNT(__argc), const char *, const struct option *, int * )
man page · December 24, 2022
getopt_long_only(3) — get long options from command line argument listmacro_GETOPT
#define _GETOPT
functiongetopt
__DARWIN_ALIAS(getopt)
int getopt(int __argc, char *_LIBC_CSTR const [_LIBC_COUNT(__argc)], const char *)man page · June 5, 2014
getopt(3) — get option character from command line argument listvariableoptind
extern int optind
macro_OPTRESET
#define _OPTRESET