cla...">

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

What does this warning mean?

Here is the ISS.

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

      

If I compile this single file with ctrl+F7

in Visual Studio 2015, I get this warning.

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

      

I appear on my computer, but http://rextester.com is unable to reproduce this warning.

Other information: -

  • Note that it is TTT<K>

    never created.
  • If I delete the word alignas(alignof(K))

    , the warning goes away.
  • With some test cases, this class is practically usable.

I cannot find any sites that have any useful description.

Has anyone ever encountered this before?

+3


source to share


1 answer


Reading, for example. this alignas

link
, it must be placed between the keyword struct

or union

and the struct / union tag.

So it should be something like



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

      

+5


source







All Articles