Argument-parsing helpers for C/Unix
Solution 1:
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.
Solution 2:
As the saying goes, "standard is better than better". So I always use getopt_long() and anything that is non-GNOME/glibby, and the glib one on anything that does.
For the same reason I always use optparse in Python applications, even though it has a lot of missing features relative to getopt_long() ... but that's the Python standard.