导出类
为什么能够这样定义
class __declspec( dllexport ) CMyClass;
而不能
__declspec( dllexport ) class CMyClass;
但是变量导出方式下面两种方法皆可呢?
__declspec( dllexport ) int nLen;int __declspec ( dllexport) nLen;
为什么能够这样定义
class __declspec( dllexport ) CMyClass;
而不能
__declspec( dllexport ) class CMyClass;
但是变量导出方式下面两种方法皆可呢?
__declspec( dllexport ) int nLen;int __declspec ( dllexport) nLen;
class AFX_EXT_CLASS CMyClass;
AFX_EXT_DATA
为什么 class __declspec( dllexport ) CMyClass; 可以
而 __declspec( dllexport ) class CMyClass;不可以
但是
为什么对于导出变量nLen两种方式都可以
人家不都告诉你了吗?怎么还问。就像你定义类为什么要用class呀,你要人家怎么给你解释呀?
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.to taoni(taoni)你现在明白我为什么还要问了么?
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-specifier
int __declspec(selectany) * pi2 = 0; //OK, selectany & int both part of decl-specifier
int * __declspec(selectany) pi3 = 0; //ERROR, selectany is not part of a declarator