加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 用于GNU getopt()的-W选项是什么?

发布时间:2020-12-16 09:41:49 所属栏目:百科 来源:网络整理
导读:引自 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 fo
引自 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_long,getopt_long_only)只能理解短选项.

解决方法

退房: 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读