2016-05-25 117 views
10

GCC 6.1.1使我对C已过时的声明警告++代码弃用结构成员C++

struct foo 
{ 
    __attribute__ ((deprecated)) static const int a = 1; 
}; 


dep.cpp:1:8: warning: ‘foo::a’ is deprecated [-Wdeprecated-declarations] 
    struct foo 
      ^~~ 
dep.cpp:3:50: note: declared here 
    __attribute__ ((deprecated)) static const int a = 1; 

documentation说:“在警告已被废弃的属性的结果,如果变量的任何地方在源文件中使用“。

由于预警点到第一线(结构富),这是否意味着,因为结构是“使用”过时的成员将出现警告? 有没有办法使用静态const struct成员的弃用属性?

GCC 4.9.3似乎没有给出这个警告。

+0

看起来像一个bug –

+4

可能是一个编译器错误 - GCC很可能得到由“= 1”的部分混淆,并且将其解释为使用。 –

+0

@ M.M:你用'clang ++'试过了吗? – Destructor

回答