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
Licenses
Operating Systems
Implementation

RSS Recent releases

  •  08 Nov 2012 02:49

Release Notes: A compilation problem in Mac OS X has been fixed. The versiontext directive has been added. The commandline option --strict-hidden has been added. Many bugs have been fixed.

  •  25 Sep 2011 18:11

    Release Notes: Wrapping and preprocessing of strings is correctly handled. Enum variables are initialized with a generated null value (this makes the parser compilable in C++). Warnings in the generated parser when only flags are used are now removed.

    •  23 Dec 2009 21:07

    Release Notes: This release has switched to using a git repository. Other gcc compilation warnings on generated files were removed.

    •  01 Oct 2009 12:47

    Release Notes: Enum option values can now contain + and -. Compilation problems due to the FIX_UNUSED macro not being in the right place were fixed. --header-output-dir and --src_output-dir command line options were added to store cmdline.h separately from cmdline.c. Generated functions use prototypes with char ** instead of char *const *.

    •  13 Jun 2009 19:40

    Release Notes: 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.

    RSS Recent comments

    01 Oct 2006 01:11 Avatar bettini

    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.

    25 Sep 2006 03:48 jmansion

    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.

    20 Dec 1999 20:05 devphil

    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.

    Screenshot

    Project Spotlight

    cwwav

    A program to generate Morse code sound files from text.

    Screenshot

    Project Spotlight

    Kawaii Emoji Messenger

    A multiplatform Facebook client based on the idea of bringing emoji to the desktop.