Projects / GNU gengetopt

GNU gengetopt

GNU gengetopt takes a simple description of arguments and generates a C function that uses the GNU getopt_long(3) function to parse and validate the options. It is perfect if you are too lazy to write all that is required to call getopt_long(3), or need to use many options. The generated code also works with autoconf or automake.

Tags Software Development Utilities
Licenses GPL
Operating Systems OS Independent
Implementation C C++

Tweet this project Short link

Rss Recent releases

  • Rrelease-mid
  •  13 Jun 2009 19:40
  • Rrelease-after

Changes: Further compilation warnings for generated files were removed. A compilation problem for files generated with --include-getopt with some versions of stdlib.h was fixed. The dependency on the flex library (which generated problems in compilation in Open Solaris) was removed. PACKAGE_NAME, if defined, is used for printing help and version. The configure option --docdir is now used, if specified for installing documentation.

  • Rrelease-mid
  •  26 Apr 2008 18:07
  • Rrelease-after

Changes: Compilation warnings for generated files were removed. A bug with --long-help and enum options was fixed and the output of --help and output of --show-help now correspond. A compilation problem in generated output with mode options was fixed.

  • Rrelease-mid
  •  14 Jan 2008 14:19
  • Rrelease-after

Changes: The generated code was highly refactored in order to be cleaner and easier to understand. Many bugs were fixed. A list of possible values can have types (instead of only strings). Options can be given more details. Mode options were added: mutually exclusive groups of options.

  • Rrelease-mid
  •  05 Jul 2007 11:09
  • Rrelease-after

Changes: This release fixes some bugs when --include-getopt is specified. In help output, a section is not generated if all its options are hidden. The option --default-optional, which allows specifying that all options are by default optional, was added. A bug corrupting memory when using args entry in the .ggo file was fixed.

  • Rrelease-mid
  •  18 Jan 2007 05:49
  • Rrelease-after

Changes: Compilation problems that could make 'make check' fail on some systems lacking getopt_long were fixed along with a test problem when not using GNU sed. In strings, # comments are now not considered.

Rss Recent comments

Rcomment-before 01 Oct 2006 01:11 Rcomment-trans bettini Rcomment-after

Re: Almost...

>

> % we aren't running Linux so we

> % don't have the GNU C library, and so

> we

> % don't have getopt_long. That,

>

>

> I just grabbed a netbsd libc and pulled

> getopt_long from that. Its a bit of

> work to remove all the references to the

> libc build framework common bits, bit a

> heck of a lot easier than writing a

> generator.

>

> I think pretty much any *BSD libc will

> do - most include the code from netbsd

> as far as I know.

>

> You should be able to use the CVS

> viewers to get the code without having a

> full distro handy.

>

gengetopt comes with a version of getopt.h getopt.c and getopt1.c and they are all you need to use getopt_long if it doesn't come with libc.

Also, in the manual, there's a chapter explaining how to deal with missing getopt_long.

Hope it helps.

Rcomment-before 25 Sep 2006 03:48 Rcomment-trans jmansion Rcomment-after

Re: Almost...

> we aren't running Linux so we

> don't have the GNU C library, and so we

> don't have getopt_long. That,

I just grabbed a netbsd libc and pulled getopt_long from that. Its a bit of work to remove all the references to the libc build framework common bits, bit a heck of a lot easier than writing a generator.

I think pretty much any *BSD libc will do - most include the code from netbsd as far as I know.

You should be able to use the CVS viewers to get the code without having a full distro handy.

Rcomment-before 20 Dec 1999 20:05 Rcomment-trans devphil Rcomment-after

Almost...
This is almost exactly what I was about to write myself. I haven't seen
the code, just the homepage. The only thing that makes it unsuitable for
use on my systems is that (heinous sin) we aren't running Linux so we
don't have the GNU C library, and so we don't have getopt_long. That,
and modifying main() isn't what I had in mind...

If I end up writing another option generator, I'll mention this one in the
documentation as an alternative that supports getopt_long.

E9ba94f3eb7ee961bbabd1a4a8ccdc42_thumb

Project Spotlight

GNMS

A tool to monitor the states of network elements.

806f3574aa004ab418f40776b0207e64_thumb

Project Spotlight

Addjob

A program that lets you distribute jobs over a network.