gpt4 book ai didi

c - GNU getopt() 的 -W 选项有什么用?

转载 作者:IT王子 更新时间:2023-10-29 01:02:08 27 4
gpt4 key购买 nike

引自the POSIX.1-2008 description about -W option ,

The -W (capital-W) option shall be reserved for vendor options.

引自 Linux 手册页,GNU getopt handles -W option as follows :

If optstring contains W followed by a semicolon ( ; ), then -W foo is treated as the long option --foo. (The -W option is reserved by POSIX.2 for implementation extensions.)

有人能以更清楚(直截了当)的方式解释上面的句子并解释为什么这样的选项有用吗?

上面的陈述让我感到困惑,因为我认为 getopt(不是 getopt_longgetopt_long_only)只理解空头选项。

最佳答案

checkout :http://www.gnu.org/software/gnuprologjava/api/gnu/getopt/Getopt.html

Long options can also be specified using a special POSIX argument format (one that I highly discourage). This form of entry is enabled by placing a "W;" (yes, 'W' then a semi-colon) in the valid option string. This causes getopt to treat the name following the "-W" as the name of the long option. For example, "-W outputdir=foo" would be equivalent to "--outputdir=foo". The name can immediately follow the "-W" like so: "-Woutputdir=foo". Option arguments are handled identically to normal long options. If a string follows the "-W" that does not represent a valid long option, then getopt() returns 'W' and the caller must decide what to do. Otherwise getopt() returns a long option value as described below.

关于c - GNU getopt() 的 -W 选项有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14338223/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com