Microsoft Specific

原创 2006年06月15日 00:50:00

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 listed below. 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. The extended attribute syntax simplifies and standardizes Microsoft-specific extensions to the C and C++ languages.

This is the extended attribute grammar for C++:


decl-specifier :
__declspec ( extended-decl-modifier-seq )
extended-decl-modifier-seq :
extended-decl-modifier extended-decl-modifier-seq
extended-decl-modifier :
property({get=get_func_name|, put=put_func_name})

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

Extended attribute grammar supports these Microsoft-specific storage-class attributes: align, allocate, deprecated, dllexport, dllimport, naked, noinline, noreturn, nothrow, novtable, selectany, and thread. It also supports these COM-object attributes: property and uuid.

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. 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.

The __declspec keywords should be placed at the beginning of a simple declaration. The compiler ignores, without warning, any __declspec keywords placed after * or & and in front of the variable identifier in a declaration.

A __declspec attribute specified in the beginning of a user-defined type declaration applies to the variable of that type. For example:

(dllimport) class X {} varX;

In this case, the attribute applies to varX. A __declspec attribute placed after the class or struct keyword applies to the user-defined type. For example:

class (dllimport) X {};

In this case, the attribute applies to X.

The general guideline for using the __declspec attribute for simple declarations is as follows:

decl-specifier-seq init-declarator-list;

The decl-specifier-seq should contain, among other things, a base type (e.g. int, float, a typedef, or a class name), a storage class (e.g. static, extern), or the __declspec extension. The init-declarator-list should contain, among other things, the pointer part of declarations. For example:

(selectany) int * pi1 = 0;   //OK, selectany & int both part of decl-specifier
int (selectany) * pi2 = 0;   //OK, selectany & int both part of decl-specifier
int * (selectany) pi3 = 0;   //ERROR, selectany is not part of a declarator

The following code declares an integer thread local variable and initializes it with a value:

// Example of the  keyword
( thread ) int tls_i = 1;

END Microsoft Specific


Microsoft Specific

Microsoft SpecificThe extended attribute syntax for specifying storage-class information uses the __...
  • hygol
  • hygol
  • 2006年06月14日 14:09
  • 794

DSL(Domain Specific language)

第一次听到DSL(Domain Specific language)还是去年春节前和Edwin的一次咖啡馆的聊软件工厂时候。 在真正了解领域模型(领域内的概念类或现实世界中对象的可视化表示的模型)前...
  • dazhi_100
  • dazhi_100
  • 2014年09月22日 22:24
  • 834

eclipse配置:save action-->enable project specific settings

项目名-->右键-->properties-->save action:把“enable project specific settings”前面的对勾去掉 这个选项的意思是:类里引用的ja...
  • jim_007
  • jim_007
  • 2017年06月06日 15:56
  • 1087

Unit 'xxxxxx' is specific to a platform

1:如果编译的时候,经常出现类似这种警告     warning W1005: W1005 Unit 'FileCtrl' is specific to a platform      w...
  • stbaby
  • stbaby
  • 2013年12月11日 13:42
  • 1073


  • liujinwei2005
  • liujinwei2005
  • 2012年12月14日 21:14
  • 5220


1. the seven habits of highly effective teens 《高效能人士的七个习惯》是我非常欣赏的一本书,这是一个系列,把七个习惯应用在工作关系上,家庭关系上,还给...
  • dingxy
  • dingxy
  • 2013年09月13日 11:57
  • 2610

Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a

Server Error in  /  Application. -------------------------------------------------------------------...
  • feifeiyaqi3
  • feifeiyaqi3
  • 2007年10月25日 16:22
  • 14940

并查集系列(二)——Union-find with specific canonical element

Union-find with specific canonical element.
  • h893456070
  • h893456070
  • 2016年11月14日 16:26
  • 293

Machine Learning「Week1」

Machine Learning「Week1」Machine LearningWeek1 Introduction Supervised Learning Unsupervised Learning ...
  • ACMer_hades
  • ACMer_hades
  • 2017年05月21日 20:57
  • 198

走近“领域特定语言”(Domain-Specific Languages)

领域特定语言(Domain-Specific Languages,简称DSL),是一个很有用的术语和概念,但其边界很模糊。一些东西很明显是DSL,但另一些可能会引发争议。本文接下来就走近“领域特定语言...
  • hzbooks
  • hzbooks
  • 2013年03月26日 14:50
  • 5886
您举报文章:Microsoft Specific