[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.15 Using getopt(3C)

There is a template named, ‘getopt.tpl’ that is distributed with AutoOpts. Using that template instead of ‘options.tpl’ will produce completely independent source code that will parse command line options. It will utilize either the standard getopt(3C) or the GNU getopt_long(3GNU) function to drive the parsing. Which is used is selected by the presence or absence of the long-opts program attribute. It will save you from being dependent upon the libopts library and it produces code ready for internationalization. However, it also carries with it some limitations on the use of AutoOpts features and some requirements on the build environment.

PLEASE NOTE: in processing the option definitions to produce the usage text, it is necessary to compile some generated code in a temporary directory. That means that all the include directories needed to compile the code must be full path names and not relative directory names. “.” is a relative directory name. To specify “-I.” in the CFLAGS environment variable, you must expand it. For example, use:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.