Scroll to navigation

getopt_long_only(3) Library Functions Manual getopt_long_only(3)

NAME

getopt_long_only - parse long command-line options

LIBRARY

Standard C library (libc-lc)

SYNOPSIS

#define _GNU_SOURCE
#include <getopt.h>
int getopt_long_only(int argc, char *argv[],
           const char *optstring,
           const struct option *longopts, int *longindex);

DESCRIPTION

getopt_long_only() is like getopt_long(3), but '-' as well as "--" can indicate a long option. If an option that starts with '-' (not "--") doesn't match a long option, but does match a short option, it is parsed as a short option instead.

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).

Interface Attribute Value
getopt_long_only () Thread safety MT-Unsafe race:getopt env

STANDARDS

GNU.

SEE ALSO

getopt(1), getopt(3), getopt_long(3), getsubopt(3)

2025-12-07 Linux man-pages (unreleased)