title: Argument-parsing helpers for C/Unix
body: <p>I know of the following:</p>
  
  <ul>
  <li>The venerable <code>getopt(3)</code></li>
  <li>The extended <code>getopt_long</code></li>
  <li>glibc's <a href="http://www.gnu.org/software/libtool/manual/libc/Argp.html" rel="noreferrer"><code>argp</code></a> parser for Unix-style argument vectors</li>
  <li><a href="http://developer.gnome.org/arch/misc/popt.html" rel="noreferrer">popt</a> from the GNOME project (or its spiritual successor in <a href="http://library.gnome.org/devel/glib/stable/glib-Commandline-option-parser.html" rel="noreferrer">Glib</a>)</li>
  </ul>
  
  <p>I'm sure there's more that I haven't used or even heard of; a quick Google search reveals <a href="http://www.purposeful.co.uk/software/gopt/" rel="noreferrer">Gopt</a>, <a href="http://argtable.sourceforge.net/" rel="noreferrer">argtable</a>, and <a href="http://michael.dipperstein.com/optlist/" rel="noreferrer">Optlist</a>.</p>
  
  <p>Personally, I like <code>argp</code> best, and every program I wrote using <code>getopt</code>/<code>getopt_long</code> (beyond a certain baseline of complexity) has been converted to use <code>argp</code>. It's more widely available than <code>popt</code>, more powerful than <code>getopt_long</code>, well-documented, consistent with all the GNU-style conventions, and very flexible. On the downside, it's far from the easiest to use (thanks to being so flexible), and the code to support it is quite verbose (as are many things in C).</p>
  
  <p>What do you use, and why?</p>
  
  <p>Yes, I mean C rather than C++. There are a ton of C++ parsers, but I don't use C++.</p>
  
  <p>John Millikin notes that <code>popt</code> is no longer maintained.  I list it because many programs still use it -- including AbiWord, rpm, rsync, and samba -- despite Gnome's efforts to <a href="http://live.gnome.org/ProjectRidley" rel="noreferrer">migrate away</a>. But I've added a link to Glib's argument parser now, too.</p>
  
  <hr/>
  
  <p>For C++ argument parsing, see the question <em><a href="https://stackoverflow.com/questions/253556/what-parameter-parser-libraries-are-there-for-c">What parameter parser libraries are there for C++?</a></em></p>