A good C alternative for Boost.Program_options?
Any good alternative written in C to replace Boost.Program_options? Given it's able to parse:
- Short options like -h
- Long options like --help --input-file
- Parse repeated keys/options
- Accepts key-value pairs: --mysql=/usr/lib
- Parsing environmental variables and XML/INI 开发者_StackOverflowfiles is optional.
If you are okay with the GPL license, you want GNU getopt.
GLib comes with a commandline option parser that supports your first four requirements, and also a key-value file parser that supports the fifth.
POSIX has getopt
, glibc adds getopt_long
. Both the links I posted have examples. None of them parses environment variables of XML/INI files, but those two don't really belong with command-line options parsing. A quick google search results in libraries to be able to do those things though.
精彩评论