[英]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無法重現此警告。
其他信息: -
TTT<K>
永遠不會真正實例化。 alignas(alignof(K))
這個詞,警告就會消失。 我真的找不到任何有關它的有用描述的網站。
有沒有人曾經遇到過它?
讀取例如這個alignas
引用它應該放在struct
或union
關鍵字和structure / union標記之間。
所以應該是這樣的
template<class K> struct TTT{
union alignas(alignof(K)) {
// ^^^^^^^^^^^^^^^^^^^
// Note placement
char raw[sizeof(K)];
K rawK;
};
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.