Extended Attribute Syntax

The extended attribute syntax for specifying storage-class information uses the __declspec keyword, which specifies that an instance of a given type is to be stored with a Microsoft-specific storage-class attribute (thread, naked, dllimport, dllexport, nothrow, property, selectany, or uuid). Examples of other storage-class modifiers include the static and extern keywords. However, these keywords are part of the ANSI specification of the C and C++ languages, and as such are not covered by extended attribute syntax.

This is the extended attribute syntax for C++:

Syntax

decl-specifier :

__declspec ( extended-decl-modifier-seq )

extended-decl-modifier-seq :

extended-decl-modifieropt
extended-decl-modifier extended-decl-modifier-seq

extended-decl-modifier :

thread
naked
dllimport
dllexport
nothrow
property
selectany
uuid(“
ComObjectGUID”)

White space separates the declaration modifier sequence. Examples of the syntax appear in later sections.

The thread, naked, dllimport, dllexport, nothrow, property, selectany, and uuid storage-class attributes are properties only of the declaration of the object or function to which they are applied. Unlike the __near and __far keywords, which actually affect the type of object or function (in this case, 2- and 4-byte addresses), these storage-class attributes do not redefine the type attributes of the object itself. The thread attribute affects data and objects only. The naked attribute affects functions only. The dllimport and dllexport attributes affect functions, data, and objects. The property, selectany, and uuid attributes affect COM objects.