【问题标题】:Difference between '-std' and '--std' compiler flags“-std”和“--std”编译器标志之间的区别
【发布时间】:2016-02-06 13:23:35
【问题描述】:

我注意到-std--std 都用于设置编译标准。在std 之前使用--- 有什么区别?

我在谷歌上搜索并找到了this,但它似乎没有提及std 之前的单连字符与双连字符的任何内容。

【问题讨论】:

    标签: gcc compiler-flags


    【解决方案1】:

    -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 },
       ...
      };
    

    【讨论】:

    • 谢谢!我不知道!
    猜你喜欢
    • 2014-03-04
    • 2013-01-18
    • 2012-04-25
    • 2015-07-21
    • 2012-10-27
    • 1970-01-01
    • 1970-01-01
    • 2014-09-17
    • 2021-07-10
    相关资源
    最近更新 更多