__declspec
Go Up to Keywords, Alphabetical Listing Index
Category
Modifiers (C++), Keyword Extensions, Storage Class Specifiers (C++)
Contents
Syntax
__declspec(<decl-modifier>)
Description
Use the __declspec keyword to indicate the storage class attributes for a variable or function.
The __declspec keyword extends the attribute syntax for storage class modifiers so that their placement in a declarative statement is more flexible. The __declspec keyword and its argument can appear anywhere in the declarator list, as opposed to the old style modifiers, which could only appear immediately preceding the identifier to be modified.
__export void f(void); // illegal
void __export f(void) // correct
void __declspec(dllexport) f(void); // correct
__declspec(dllexport)void f(void); // correct
class __declspec(dllexport) ClassName { } // correct
Modifiers
Directive | Description | Alternative |
---|---|---|
__declspec(allocate("SEGNAME")) | Specifies the segment in which the entity is allocated. | #pragma codeseg |
__declspec(delphiclass) | Indicates that this class derives from TObject and should be Delphi- and VCL-compatible. | |
__declspec(delphirecord) | Indicates that this structure is a Delphi record (in C++ code generated automatically from Delphi code). | |
__declspec(delphireturn) | Specifies that this type should be VCL-compatible so that it could be passed by value in function calls. | |
__declspec(delphirtti) | Indicates that for this class' public or published members Delphi RTTI should be generated. | |
__declspec(dllexport) | Specifies that this entity should be imported when building a shared library. | _export, __export |
__declspec(dllimport) | Specifies that this entity should be exported when building a shared library. | _import, __import |
__declspec(dynamic) | Specifies that this function is dynamic (similar to virtual). | |
__declspec(naked) | Specifies that this function should not have prolog and epilog code. | |
__declspec(hidesbase) | Specifies that this member function has no relation to any virtual functions with the same name in any of the base classes. | |
__declspec(noreturn) | Specifies that this function does not return. | #pragma noretval, C++11 attribute noreturn |
__declspec(nothrow) | Specifies that the function does not throw any exception. | |
__declspec(novtable) | Specifies that the code to initialize the class' vtable should not be generated. | |
__declspec(package) | Indicates that this class definition can be compiled in a package. | |
__declspec(pascalimplementation) | Indicates that this class is defined in Delphi. | |
__declspec(property) | Defines a property with the given read and/or write access. | __property |
__declspec(selectany) | Indicates that this global data is initialized in more than one source file and any initialization code can be selected for the definition. | |
__declspec(thread) | Indicates that this entity is local to the thread (thread-local storage). | __thread |
__declspec(uuid("ComObjectGUID")) | Associates the class with a globally unique identifier (GUID). |