簡體   English   中英

“C4649:屬性在此上下文中被忽略”是什么意思?

[英]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引用它應該放在structunion關鍵字和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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM