getopt()如何解析-Wall这样的参数
本帖最后由 leiing 于 2016-08-09 14:43 编辑看资料getopt只能解析短参数的,如-c -o -E,而getopt_long是解析长参数的,如--help。
但是像-Wall,只有一个横线,但有多个字符,如何解析?
int opt = 0;
static const char *optString = "Il:o:vh?";
opt = getopt( argc, argv, optString );
while( opt != -1 ) {
switch( opt ) {
case 'I':
break;
case 'l':
break;
case 'o':
break;
case 'v':
break;
case 'h': /* fall-through is intentional */
case '?':
display_usage();
break;
default:
/* You won't actually get here. */
break;
}
opt = getopt( argc, argv, optString );
}
谢谢。
leiing 发表于 2016-08-04 17:10 static/image/common/back.gif
看资料getopt只能解析短参数的,如-c -o -E,而getopt_long是解析长参数的,如--help。
但是像-Wall,只有一个横线,但有多个字符,如何解析?
-Wall 通常等效于 -W -a -l -l 回复 1# leiing
getopt_long_only
页:
[1]