相关疑难解决方法(0)

g ++使用-Wpedantic选项编译C++ 11:是否有一个选项可以仅禁用有关未命名结构的警告?

我想保留任何其他检查-Wpedantic,但会丢失有关未命名结构的警告error: ISO C++ prohibits anonymous structs [-Wpedantic].

我希望能够做到以下几点:

union
{
  struct
  {
    float x, y, z, w;
  };
  struct
  {
    float r, g, b, a;
  };

  float v[4];
};
Run Code Online (Sandbox Code Playgroud)

到目前为止我发现了什么

我正在使用C++ 11并使用-std=c++11标志进行编译.我已经读过C11支持这个功能,但我还没有看到它在C++ 11中得到支持.

我曾经提到过-fms-extensions:

我尝试了旗帜,它似乎没有任何效果(无论在-fms-extensions和之间排序的排列-Wpedantic).

编辑 - 更多细节

感谢我的评论,我发现了以下内容:

我仍然想知道是否有一种方法可以启用此gcc扩展(我知道所有编译器都有)将禁用该警告.或者是-Wpedantic全有还是全无?

c++ gcc c++11

7
推荐指数
1
解决办法
4317
查看次数

没有名字的班级

我在C++标准文档中读到了关于类的内容:

类是一种类型.它的名称在其范围内成为类名(9.1).

class-name: identifier template-id
Run Code Online (Sandbox Code Playgroud)

我在C++标准中找到了这个标识符的语法:

 2.10 Identifiers
 identifier: nondigit
 identifier nondigit
 identifier digit

 nondigit: one of universal-character-name 
 _ a b c d e f g h i j k l m n o p q r s t u  v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
 digit: one of 0 1 2 3 4 5 …
Run Code Online (Sandbox Code Playgroud)

c++ grammar class identifier

2
推荐指数
1
解决办法
3433
查看次数

标签 统计

c++ ×2

c++11 ×1

class ×1

gcc ×1

grammar ×1

identifier ×1