C 扩展的存储类特性C Extended Storage-Class Attributes

Microsoft 专用Microsoft Specific

有关本主题的更多最新信息可以在 __declspec(C++ 参考)下找到。More up-to-date information on this topic can be found under __declspec (C++ Reference).

扩展的特性语法简化并标准化了特定于 Microsoft 的 C 语言扩展。Extended attribute syntax simplifies and standardizes the Microsoft-specific extensions to the C language. 使用扩展的特性语法的存储类特性包括 thread、naked、dllimport 和 dllexport。The storage-class attributes that use extended attribute syntax include thread, naked, dllimport, and dllexport.

用于指定存储类信息的扩展特性语法使用 __declspec 关键字,这指定给定类型的实例将与特定于 Microsoft 的存储类特性(thread、naked、dllimport 或 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). 其他存储类修饰符的示例包括 static 和 extern 关键字。Examples of other storage-class modifiers include the static and extern keywords. 但是,这些关键字是 ANSI C 标准的一部分,因此未涵盖在扩展的特性语法中。However, these keywords are part of the ANSI C standard and as such are not covered by extended attribute syntax.


__declspec ( extended-decl-modifier-seq ) /* Microsoft 专用 */__declspec ( extended-decl-modifier-seq ) /* Microsoft Specific */

extended-decl-modifier optextended-decl-modifier opt

extended-decl-modifier-seq extended-decl-modifierextended-decl-modifier-seq extended-decl-modifier





空格可分隔声明修饰符。White space separates the declaration modifiers. 请注意,extended-decl-modifier-seq 可以为空;在此情况下,__declspec 不起作用。Note that extended-decl-modifier-seq can be empty; in this case, __declspec has no effect.

thread、naked、dllimport 和 dllexport 存储类特性仅为它们应用于的数据或函数的声明的属性;它们不重新定义函数自身的类型特性。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. thread 特性只影响数据。The thread attribute affects data only. naked 特性仅影响函数。The naked attribute affects functions only. dllimport 和 dllexport 特性影响函数和数据。The dllimport and dllexport attributes affect functions and data.

结束 Microsoft 专用END Microsoft Specific

请参阅See Also

声明和类型Declarations and Types