Argument-parsing helpers for C/Unix

GNU has gengetopt which generates code for an options data structure and the getopt_long code to parse the command line and fill the structure.. It’s fairly easy to learn and works well.

As a bonus you can pass the options structure around your code and avoid global storage if desired.

It provides GNU style semantics (obviously), and is small enough to simply include with the project for distribution if you’re not sure of your audience’s build environment.

Leave a Comment