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

7.4.5 Using the example options

Normally, however, you would not use the main clause. Instead, the file would be named something like ‘checkopt.def’, you would compile ‘checkopt.c’ the usual way, and link the object with the rest of your program.

The options are processed by calling optionProcess (see section optionProcess):

 
main( int argc, char** argv )
{
  {
    int optct = optionProcess( &checkOptions, argc, argv );
    argc -= optct;
    argv += optct;
  }

The options are tested and used as in the following fragment. ENABLED_OPT is used instead of HAVE_OPT for the ‘--show-defs’ option because it is an enabled/disabled option type:

 
  if (  ENABLED_OPT( SHOW_DEFS )
     && HAVE_OPT( CHECK_DIRS )) {
    int    dirct = STACKCT_OPT( CHECK_DIRS );
    char** dirs  = STACKLST_OPT( CHECK_DIRS );
    while (dirct-- > 0) {
      char* dir = *dirs++;
      ...

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