Compiler Warning (level 2) C4091

'extended-attribute' : ignored on left of 'type' when no variable is declared

A __declspec attribute specified in the beginning of a user-defined type declaration applies to the variable of that type. This compiler warning is generated when no variable is declared. For example:

__declspec(dllimport) class X {}; // generates C4091

// correct: the __declspec attribute applies to varX
__declspec(dllimport) class X {} varX;

The __declspec attribute placed after the class or struct keyword applies to the user defined type. For example:

class __declspec(dllimport) X {};

In this case, the __declspec attribute applies to X.