Reputation: 3087
Is it bad form to use the GNU getopt in C++ programs? Is there a C++ specific alternative, or should I still just use getopt?
Upvotes: 12
Views: 5705
Reputation: 2964
I like TCLAP (http://tclap.sourceforge.net/) the Templatized C++ Command Line Parser Library.
Upvotes: 2
Reputation: 1448
Try CLPP library. It's simple and flexible library for command line parameters parsing. Header-only and cross-platform. Uses ISO C++ and Boost C++ libraries only. IMHO it is easier than Boost.Program_options.
Library: http://sourceforge.net/projects/clp-parser
26 October 2010 - new release 2.0rc. Many bugs fixed, full refactoring of the source code, documentation, examples and comments have been corrected.
Upvotes: 2
Reputation: 27552
There is nothing wrong with using getopt. There are a multitude of object oriented alternatives floating around including Boost.Program_options, and classes in POCO, and ACE.
Upvotes: 9
Reputation: 27201
Look at this: http://michael.dipperstein.com/optlist/index.html
Upvotes: 2
Reputation: 4953
Not at all, getopt
is perfectly fine in C++. The Boost::program_options require that the Boost library be installed, which many may not have.
Upvotes: 3
Reputation: 62073
I don't know that there's anything wrong with using getopt. But you might want to look at Boost.Program_options.
Upvotes: 5