__declspec(deprecated) void func1(int) { printf("func1n");}
__declspec(deprecated("** this is a deprecated function **")) void func2(int) { printf("func2n");}
__declspec(deprecated(MY_TEXT)) void func3(int) { printf("func3");}
int main()
{
fun1();
fun2();
fun3();
}
4.dllimport 和 dllexport
用 __declspec(dllexport), __declspec(dllimport)显式的定 义 dll 接口给调 用它的 exe 或
dll
文件,用 dllexport 定义的函数不再需要(.def)文件声明这些函数接口了。注意:
若在 dll
中定义了模板类那它已经隐式的进行了这两种声明,我们只需在 调用的时候
实例化即可。
e.g 常规方式 dll 中
class ___declspec(dllexport)
testdll{
testdll(){};
~testdll(){};
};
调用客户端中声明
#import comment(lib, "**.lib)
class ___declspec(dllimportt)
testdll{
testdll(){};
~testdll(){};
};
e.g 模板类:dll 中
template<class t>
class test{
test(){};
~test(){};
}
调用客户端中声明
int main()
{
test< int > b;
return 0;
}
5. jitintrinsic
用__declspec(jitintrinsic)标记一个函数或元素为 64 位公共语言运行时。具体用法未见