"C4649: attributes are ignored in this context"是什么意思?

What is the meaning of "C4649: attributes are ignored in this context"?

这个警告是什么意思?

这是mcve。

template<class K> class TTT{
    public: alignas(alignof(K)) 
    union{ 
        char raw[sizeof(K)];        
        K rawK;
    }; //<-- error at this line
};

如果我在 Visual Studio 2015 年使用 ctrl+F7 编译这个单个文件,我将收到此警告。

warning C4649: attributes are ignored in this context
note: see reference to class template instantiation 'TTT<K>' being compiled

我出现在我的计算机中,但是 http://rextester.com 无法重现此警告。

其他信息:-

我真的找不到任何网站对此有一些有用的描述。

有没有人遇到过?

阅读,例如this alignas reference 它应该放在 structunion 关键字和 structure/union 标签之间。

所以应该是这样的

template<class K> struct TTT{
    union alignas(alignof(K)) {
    //    ^^^^^^^^^^^^^^^^^^^
    //    Note placement
        char raw[sizeof(K)];        
        K rawK;
    };
};