【发布时间】:2016-02-06 13:23:35
【问题描述】:
我注意到-std 和--std 都用于设置编译标准。在std 之前使用- 和-- 有什么区别?
我在谷歌上搜索并找到了this,但它似乎没有提及std 之前的单连字符与双连字符的任何内容。
【问题讨论】:
标签: gcc compiler-flags
我注意到-std 和--std 都用于设置编译标准。在std 之前使用- 和-- 有什么区别?
我在谷歌上搜索并找到了this,但它似乎没有提及std 之前的单连字符与双连字符的任何内容。
【问题讨论】:
标签: gcc compiler-flags
-std=c99 可以,但-std c99 是一个错误。 --std c99 和 --std=c99 一样有效。这是唯一的区别。
您可以看到它们映射到opts-common.c 中的相同操作:
struct option_map
{
/* Prefix of the option on the command line. */
const char *opt0;
/* If two argv elements are considered to be merged into one option,
prefix for the second element, otherwise NULL. */
const char *opt1;
/* The new prefix to map to. */
const char *new_prefix;
/* Whether at least one character is needed following opt1 or opt0
for this mapping to be used. (--optimize= is valid for -O, but
--warn- is not valid for -W.) */
bool another_char_needed;
/* Whether the original option is a negated form of the option
resulting from this map. */
bool negated;
};
static const struct option_map option_map[] =
{
...
{ "--std=", NULL, "-std=", false, false },
{ "--std", "", "-std=", false, false },
...
};
【讨论】: