public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Larry Hall <lh-no-personal-replies-please@cygwin.com>
To: "Mikael Åsberg" <mikas493@student.liu.se>, cygwin@cygwin.com
Subject: Re: Where did the output go and question regarding return values of getopt_long()
Date: Sun, 19 Dec 2004 19:43:00 -0000	[thread overview]
Message-ID: <6.2.0.14.0.20041219143737.04a82e30@pop.prospeed.net> (raw)
In-Reply-To: <006d01c4e5dd$7e4bda90$0200a8c0@mindcooler>

At 10:14 AM 12/19/2004, you wrote:
>Hello, consider this c++-function:
>
>void
>handle_command_line(int argc,
>                   char* const argv[],
>                   bool& verbose,
>                   vector<string>& numbers)
>{
>  const int id_numbers = 4711;
>  const int id_verbose = 4712;
>  const int id_help = 4713;
>
>  const option long_options[] =
>  {
>     {"numbers", 1, NULL, id_numbers},
>     {"verbose", 0, NULL, id_verbose},
>     {"help", 0, NULL, id_help},
>     {NULL, 0, NULL, 0}
>  };
>
>  const char* const short_options = "";
>
>  int c = 0;
>
>  while((c = getopt_long(
>            argc,
>            argv,
>            short_options,
>            long_options,
>            NULL)) != -1)
>  {
>     switch(c)
>     {
>        cout << "c = " << c << endl; /* Never shown on screen... */
>
>        case id_numbers:
>        {
>           cout << "Calling extract_numbers() with " << optarg << endl;
>
>           extract_numbers(optarg, numbers);
>
>           break;
>        }
>        case id_verbose:
>        {
>           cout << "Setting verbose = true" << endl;
>
>           verbose = true;
>
>           break;
>        }
>        case id_help:
>        {
>           cout << "TODO: Add short description regarding usage here." << endl;
>
>           exit(EXIT_SUCCESS);
>        }
>        /* c seems to equal '?' for missing parameter as well... */
>        case ':':
>        {
>           cerr << "Missing parameter." << endl;
>
>           break;
>        }
>        /* Only triggers for unknown options beginning with -- */
>        case '?':
>        {
>           cerr << "Ignoring unknown option." << endl;
>
>           break;
>        }
>        default:
>        {
>           /* Throw exception? */
>           cerr << "Should not be reached." << endl;
>        }
>     }
>  }
>}
>
>My first question is about the
>cout << "c = " << c << endl;
>inside the switch. I never see this output, why? I tried writing the output to a file as well but that file was empty when the program finished. All other "output-statements" are displayed just fine in this function (and the rest of the program).

Did you look at the warning you get from the line in question?

warning: unreachable code at beginning of switch statement



--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

  reply	other threads:[~2004-12-19 19:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-19 15:15 Mikael Åsberg
2004-12-19 19:43 ` Larry Hall [this message]
2004-12-19 20:26 Mikael Åsberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6.2.0.14.0.20041219143737.04a82e30@pop.prospeed.net \
    --to=lh-no-personal-replies-please@cygwin.com \
    --cc=cygwin@cygwin.com \
    --cc=mikas493@student.liu.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).