Windows中的storage-class Attribute

本文详细介绍了C语言中__declspec(...)属性的使用方法及参数意义。这些参数包括thread、naked、dllimport和dllexport等,它们简化并标准化了微软特定的C语言扩展。文章还说明了这些属性如何应用于数据或函数声明,并指出它们不会重新定义函数本身的类型属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 先看C语言中的可以使用的__declspec(...)的参数。
下面是拷贝的微软msdn文档中的解释:

Extended attribute syntax simplifies and standardizes the Microsoft-specific extensions to 
the C language. The storage-class attributes that use extended attribute syntax include thread,
naked, dllimport, and dllexport. 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, or dllexport).
Examples of other storage-class modifiers include the static and extern keywords.
However, these keywords are part of the ANSI C standard and as such are not covered by
extended attribute syntax. Syntax storage-class-specifier: __declspec ( extended-decl-modifier-seq ) /* Microsoft Specific */ extended-decl-modifier-seq: extended-decl-modifier opt extended-decl-modifier-seq extended-decl-modifier extended-decl-modifier: thread naked dllimport dllexport White space separates the declaration modifiers. Note that extended-decl-modifier-seq can be empty;
in this case, __declspec has no effect. The thread, naked, dllimport, and dllexport storage-class attributes are a property
only of the declaration of the data or function to which they are applied;
they do not redefine the type attributes of the function itself.
The thread attribute affects data only. The naked attribute affects functions only.
The dllimport and dllexport attributes affect functions and data. END Microsoft Specific

 2 C中的storage-class attribute要比C++少很多。
只有微软提供的编译器才识别这些东西,比如naked在windows下的gcc编译器是被忽略的,也就是不会识别。(我试验过的)

转载于:https://www.cnblogs.com/jack204/archive/2011/12/05/2276684.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值