What is the difference between argp and getopt?

I think the name is self-evident. I am making a program and I was wondering what should I use of the two and why.

+7
source share
3 answers

argp may be more flexible / powerful / etc, but getopt is part of the POSIX standard. This is the choice you should make based on whether you expect your program to be portable.

+11
source

From the Argp Guide :

Argp provides features not available in the more commonly used getopt interface. These features include automatically generating a response to the --help and --version options, as described in the GNU Coding Standards. Using argp makes it less likely that programmers will neglect to implement these additional options or maintain their date.

+3
source

There is nothing to choose, I don’t think. Argp's webpage says the following:

Argp provides features not available in the more commonly used getopt interface. These features include automatically generating a response to the --help and --version options, as described in the GNU Coding Standards. Using argp makes it less likely that programmers will neglect to implement these additional options or maintain their date.

Argp also provides the ability to combine several independent parameter parsers into one, mediation conflicts between them and the result is seamless. The library can export the argp parameter parser so that user programs can be used in conjunction with their own version of parsers, which leads to less work for user programs. Some programs can only use argument parsers exported by libraries, thereby achieving a consistent and efficient version-parsing of library abstractions.

+1
source

All Articles