[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These attributes affect some of the ways that the option data are used and made available to the program.
The contents of this attribute should be just the name of the configuration file. A "#include" naming this file will be inserted at the top of the generated header.
These values should be defined as indexed values, thus:
exit-name[0] = success; exit-desc[0] = 'Successful program execution.'; exit-name[1] = failure; exit-desc[1] = 'The operation failed or command syntax was not valid.'; |
By default, all programs have these effectively defined for them.
They may be overridden by explicitly defining any or all of these values.
Additional names and descriptions may be defined.
They will cause an enumeration to be emitted, like this one
for getdefs
:
typedef enum { GETDEFS_EXIT_SUCCESS = 0, GETDEFS_EXIT_FAILURE = 1 } getdefs_exit_code_t; |
which will be augmented by any exit-name
definitions beyond ‘1’.
Some of the generated code will exit non-zero if there is an allocation error.
This exit will always be code ‘1’, unless there is an exit named ‘no_mem’
or ‘nomem’. In that case, that value will be used. Additionally, if
there is such a value, and if die-code
is specified, then a function
nomem_err(size_t len, char const * what)
will be emitted as an inline
function for reporting out-of-memory conditions.
This attribute will cause two procedures to be added to the code file:
usage_message()
and vusage_message()
, with any applicable prefix
(see prefix
, below). They are declared in the
generated header, thus:
extern void vusage_message(char const * fmt, va_list ap); extern void usage_message(char const * fmt, ...); |
These functions print the message to ‘stderr’ and invoke the usage
function with the exit code set to 1
(EXIT_FAILURE
).
This tells AutoOpts templates to emit code for vdie()
, die()
,
fserr()
, and, possibly the nomem_err()
functions. The latter is
emitted if an exit name of ‘no-mem’ or ‘nomem’ is specified. If the
die-code
is assigned a text value, then that code will be inserted in
the vdie
function immediately before it prints the death rattle
message.
The profiles for these functions are:
extern void vdie( int exit_code, char const * fmt, va_list); extern void die( int exit_code, char const * fmt, ...); extern void fserr(int exit_code, char const * op, char const * fname); static inline void nomem_err(size_t sz, char const * what) {...} |
If usage-message
or die-code
are specified, you may also
specify that the generated functions are marked as “noreturn” with
this attribute. If this attribute is not empty, then the specified string
is used instead of “noreturn”. If “noreturn” has not been defined
before these functions are declared, then it will be “#define”-d to the
empty string. No such protection is made for any non-default value.
These functions will be declared “extern noreturn void”.
This string is inserted into the .h interface file. Generally used for
global variables or #include
directives required by
flag-code
text and shared with other program text.
Do not specify your configuration header (‘config.h’) in this
attribute or the include
attribute, however. Instead, use
config-header
, above.
AutoOpts generates macros that presume that there are no cpp
macros
with the same name as the option name. For example, if you have an option
named, ‘--debug’, then you must not use #ifdef DEBUG
in your
code. If you specify this attribute, every option name will be guarded. If
the name is #define
-d, then a warning will be issued and the name
undefined. If you do not specify this and there is a conflict, you will get
strange error messages.
This attribute may be set to any of four recognized states:
#undef
) any conflicting preprocessor macros. The code
will include compiler warnings (via #warning
). Some compilers are
not ANSI-C-99 compliant yet and will error out on those warnings. You may
compile with ‘-DNO_OPTION_NAME_WARNINGS’ to silence or mostly silence
them.
no-warning
. All of the needed
#undef
s will be emitted, without any conflict checking #warning
directives emitted.
full-enum
. The option manipulation
preprocessor macros will not token paste the option names to the index
enumeration prefix. e.g. you will need to use HAVE_OPT(INDEX_OPT_DEBUG)
instead of HAVE_OPT(DEBUG)
.
This string is inserted into the .c file. Generally used for global
variables required only by flag-code
program text.
If you are going to handle your option processing with the ‘getopt.tpl’
template instead of using libopts, then specify this attribute. It will
suppress mention of ‘--more-help’ in the generated documentation.
(getopt_long
does not support ‘--more-help’.)
This value is inserted into all global names. This will disambiguate them if more than one set of options are to be compiled into a single program.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.