From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4237 invoked by alias); 19 Dec 2004 15:15:02 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 4131 invoked from network); 19 Dec 2004 15:14:55 -0000 Received: from unknown (HELO smtp110.tiscali.dk) (62.79.79.110) by sourceware.org with SMTP; 19 Dec 2004 15:14:55 -0000 Received: from mindcooler (180.184.204.213.sol.worldonline.se [213.204.184.180]) by smtp110.tiscali.dk (8.12.10/8.12.10) with SMTP id iBJFEn5L041745 for ; Sun, 19 Dec 2004 16:14:52 +0100 (CET) (envelope-from mikas493@student.liu.se) Message-ID: <006d01c4e5dd$7e4bda90$0200a8c0@mindcooler> From: =?iso-8859-1?Q?Mikael_=C5sberg?= To: Subject: Where did the output go and question regarding return values of getopt_long() Date: Sun, 19 Dec 2004 15:15:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-SW-Source: 2004-12/txt/msg00676.txt.bz2 Hello, consider this c++-function: void handle_command_line(int argc, char* const argv[], bool& verbose, vector& 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). And my second questions is why does getopt_long() return '?' for the error when an option requires an argument but none was supplied? I thought that it would return ? for unknown option and return : for missing required parameters, but it seems to return ? for both those errors (but it ouputs the correct diagnostic). I'm using latest offical cygwin, all relevant packages up-to-date. Running fully-updated winxp pro. Thanks for any replies -- 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/