Note that there are some explanatory texts on larger screens.

plurals
  1. POArgument-parsing helpers for C/UNIX
    primarykey
    data
    text
    <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="nofollow noreferrer"><code>argp</code></a> parser for unix-style argument vectors</li> <li><a href="http://developer.gnome.org/arch/misc/popt.html" rel="nofollow 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="nofollow 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="nofollow noreferrer">Gopt</a>, <a href="http://argtable.sourceforge.net/" rel="nofollow noreferrer">argtable</a>, and <a href="http://michael.dipperstein.com/optlist/" rel="nofollow 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> <h2>Edit</h2> <p>Yes, I mean C rather than C++. There's 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="nofollow 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 <a href="https://stackoverflow.com/questions/253556/what-parameter-parser-libraries-are-there-for-c">What parameter parser libraries are there for C++?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload