getopt_long_only(3)

getopt_long_only3

Parse long command-line options

Usage

#define _GNU_SOURCE
#include <getopt.h>

int getopt_long_only(int argc, char *argv[], const char *optstring, const struct option *longopts, int *longindex);

Library

Standard C library (libc, -lc)

Overview

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).

InterfaceAttributeValue
getopt_long_only()Thread safetyMT-Unsafe race:getopt env

Releases

19 releases since Debian 1.1 (Buzz); the text changed 17 times.

  1. 1.1
  2. 1.2–1.3
  3. 2.0
  4. 2.1
  5. 2.2
  6. 3.0
  7. 3.1
  8. 4.0
  9. 5.0
  10. 6.0
  11. 7
  12. 8
  13. 9
  14. 10
  15. 11
  16. 12
  17. 13
  18. Arch

Standards

GNU.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.