Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

In C++ you can also use boost::program_options.

I don't know that there's anything wrong with using getopt. But you might want to look at Boost.Program_options.

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.

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.

I like TCLAP (http://tclap.sourceforge.net/) the Templatized C++ Command Line Parser Library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top