文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > c++ 中__declspec 的用法
侵权投诉

c++ 中__declspec 的用法

c++ 中__declspec 的用法

用__declspec(deprecated ) 说明一个函数,类型,或别的标识符在新的版本或未来版本中不再支持,你不应该用这个函数或类型。它和#pragma deprecated作用一样。

e.g

#define MY_TEXT "function is deprecated"

void func1(void) {}

__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()

上一页第2页

你可能喜欢

热门文档

相关文档

  • __declspec关键字详细用法

    __declspec 关键字详细用法 __declspec 用于指定所给定类型的实例的与 ...在 C++中,默认情况下 const 为 static;但在 C 中是正确的,其默认情况下 ...

  • _declspec用法

    用法:__declspec ( extended-decl-modifier ) extended-decl-modifier 参数如下,...在 C++中,默认情况下 const 为 static; 但在 C 中是正确的,其默认情况下 ...

  • C++中 _declspec(novtable) 的探讨

    类的成员函数里调用虚函数需要 vtable 指针, 但是 class B 是不允许产生 ... c++ 中__declspec 的用法... 6页 免费 C语言中常用的三种排序方... 2页...

  • __declspec的详细用法

    __declspec 的详细用法 __declspec 用于指定所给定类型的实例的与 Microsoft ...在 C++中,默认情况下 const 为 static;但在 C 中是正确的, 其默认情况下 ...

  • C++中&的用法总结

    C++中&的用法总结_理学_高等教育_教育专区。C++中&的用法总结(例题详解哦)一种是按位与 1 & 2 = 0 一种是取地址 int* p = &a; 一种是声明引用,...

  • C++

    __declspec 关键字详细用法 2010-03-04 15:04 __declspec 用于指定所给定类型...在 C++中,默认情况下 const 为 static;但在 C 中是正确的,其默认情况下 ...

  • C++中new 的用法大全 详细

    C++编程技巧,模板特化、模板偏特化就更是技巧性很强的东西,STL 中的 type_traits 充分借助模板特化的功能,实现了在程序编译期通过编译器来决定为每一处调用使用哪...

  • __declspec关键字详细用法_李剑

    __declspec 关键字详细用法 ---李剑编辑 __declspec 用于指定所给定类型的实例...当然, 如果你 的 DLL 里全是 C++ 的类的话,你无法在 DEF 里指定导出的...

  • declspec关键字

    我要用。一般用于使用某个 dll 的 exe 中 不使用 __declspec(dllimport) ... __declspec 和 DLL导出函... 8页 免费 C++关键字 暂无评价 4页 免费 ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email