Visual C++ Compiler Warning C4994

Message Text

'attribute': attribute is marked with the 'qualifier::' or '__qualifier::' usage qualifier, please use 'qualifier:' instead

Severity

This is a level 1 warning.

Circumstances

The qualifier is one of what the product documentation calls an attribute usage specifier:

The preferred syntax is for the qualifier to be followed immediately by a lone colon and then immediately by the attribute. Warning C4994 results if the qualifier is given as above but is followed by two colons. The qualifiers are also recognised in forms with two leading underscores, but these attract warning C4994 even when followed by just the one colon.

For example,

[
    class:coclass
]

class Test;

is perfectly valid, but

[
    class::coclass
]

class Test;

produces warning C4994, as do both

[
    __class::coclass
]

class Test;

and

[
    __class:coclass
]

class Test;

It may be that the syntax variations were worked through in development, such that they may persist in some of Microsoft’s own source code until eliminated in response to this warning, but are not known to programmers outside Microsoft, who will follow the documentation, use the syntax with no leading underscore and one colon, and thus never see this warning. This would explain why the warning is not documented.

Against that, where the product documentation for error C3750 gives an example of specifying a custom attribute’s usage, what syntax does it recommend? Yes, the apparently deprecated one with two colons.