Microsoft Specific
来源:互联网 发布:新网域名不加www 编辑:程序博客网 时间:2024/05/01 01:03
Microsoft Specific
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++:
Grammar
- decl-specifier :
- __declspec ( extended-decl-modifier-seq )
- extended-decl-modifier-seq :
- extended-decl-modifieropt
extended-decl-modifier extended-decl-modifier-seq - extended-decl-modifier :
- align(#)
allocate("segname")
deprecated
dllimport
dllexport
naked
noinline
noreturn
nothrow
novtable
property({get=get_func_name|, put=put_func_name})
selectany
thread
uuid("ComObjectGUID")
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:
__declspec(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 __declspec(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:
__declspec(selectany) int * pi1 = 0; //OK, selectany & int both part of decl-specifierint __declspec(selectany) * pi2 = 0; //OK, selectany & int both part of decl-specifierint * __declspec(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 __declspec keyword__declspec( thread ) int tls_i = 1;
END Microsoft Specific
- Microsoft Specific
- Microsoft Specific
- Using Microsoft-Specific Predefined Preprocessor Macros
- [VS 2005 IDE : C++Complier] Microsoft-Specific Modifiers' Usage
- Error = [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has o
- RAD Specific
- Project specific coding conventions
- Mysql Specific in Appfuse
- Specific Type ObjectPool
- Customer-Specific Maintenance
- Domain-Specific Modeling
- Thread-specific data
- context-specific representation
- Thread-Specific Storage
- Thread-Specific Storage
- Thread-specific data
- Thread-Specific Storage 模式
- InfoCube的specific properties
- 新域名 @live.com 和 @windowslive.com 即将上线 (from cnbeta)
- 发布一个使计算机睡觉的模块:modLetPcDormancy
- asp.net学习笔记
- C++ Primer 中文版(第4版) 不完全勘误表
- 做自己的系统分析师
- Microsoft Specific
- 我谈电信设计院
- 下拉菜单被表单挡住的几种解决方法
- FLASH VS AJAX
- UML利器--Rational Rose Enterprise Edition 2003 安装破解步骤
- Java抽取Word,PDF的四种武器
- 当Google和百度都不知道答案的时候,你去请教谁?
- 你一定要知道的71个做饭技巧
- 黑客精神祭 挖掘神秘黑客背后的故事