---
name: "getopt_long_only"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/getopt_long_only"
---

# getopt\_long\_only(3)

parse long command-line options

## 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)](/getopt_long/3.md), 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)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **getopt\_long\_only**() | Thread safety | MT-Unsafe race:getopt env |

## STANDARDS

GNU.

## SEE ALSO

[**getopt**(1)](/getopt/1.md), [**getopt**(3)](/getopt/3.md), [**getopt\_long**(3)](/getopt_long/3.md), [**getsubopt**(3)](/getsubopt/3.md)
