gcc -v以及-h处理

GCC:gcc/gcov-tool.c

/* Process args, return index to first non-arg.  */

static int process_args (int argc, char **argv) {   int opt;

  while ((opt = getopt_long (argc, argv, "+hv", options, NULL)) != -1)     {       switch (opt)         {         case 'h':           print_usage (false);           /* Print_usage will exit.  */         case 'v':           print_version ();           /* Print_version will exit.  */         default:           print_usage (true);           /* Print_usage will exit.  */         }     }

  return optind; }

/* Print a usage message and exit.  If ERROR_P is nonzero, this is an error,    otherwise the output of --help.  */

static void print_usage (int error_p) {   FILE *file = error_p ? stderr : stdout;   int status = error_p ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;

  fnotice (file, "Usage: %s [OPTION]... SUB_COMMAND [OPTION]...\n\n", progname);   fnotice (file, "Offline tool to handle gcda counts\n\n");   fnotice (file, "  -h, --help                            Print this help, then exit\n");   fnotice (file, "  -v, --version                         Print version number, then exit\n");   print_merge_usage_message (error_p);   print_rewrite_usage_message (error_p);   print_overlap_usage_message (error_p);   fnotice (file, "\nFor bug reporting instructions, please see:\n%s.\n",            bug_report_url);   exit (status); }

 

/* Print version information and exit.  */

static void print_version (void) {   fnotice (stdout, "%s %s%s\n", progname, pkgversion_string, version_string);   fnotice (stdout, "Copyright %s 2014-2016 Free Software Foundation, Inc.\n",            _("(C)"));   fnotice (stdout,            _("This is free software; see the source for copying conditions.\n"              "There is NO warranty; not even for MERCHANTABILITY or \n"              "FITNESS FOR A PARTICULAR PURPOSE.\n\n"));   exit (SUCCESS_EXIT_CODE); }

static const struct option options[] = {   { "help",                 no_argument,       NULL, 'h' },   { "version",              no_argument,       NULL, 'v' },   { 0, 0, 0, 0 } };

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值