我注意到 -std
和 --std
都可以用于设置编译标准。在 std
之前使用 -
和 --
有什么区别?
我用谷歌搜索发现this ,但它似乎没有提及有关 std
之前的单个连字符与双连字符的任何信息。
最佳答案
-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 },
...
};
关于gcc - '-std' 和 '--std' 编译器标志之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35241521/