__declspec(dllexport)的意义是什么?

thinkperson_t410 2012-02-20 04:12:31
(1)__declspec(dllexport) IMGS_EtSym* __stdcall MGS_CreateEtSymObject();

(2)__declspec(dllexport) IMGS_EtSym* __stdcall MGS_GetEtSymObject();

(3)#define _DLL_EXPORT __declspec(dllexport)
class _DLL_EXPORT IMGS_MapLayer ;


疑问:
(1)__declspec(dllexport)的意义是什么?
(2)请详细解释一下(1)(2)(3)的意义是什么?
...全文
252 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
freelancer_ex 2013-08-30
  • 打赏
  • 举报
回复
vc定义的符号导出标识,导出函数和类
thinkperson_x201 2013-08-30
  • 打赏
  • 举报
回复
__declspec(dllexport) 是告诉连接器, 将后面的符号放入导出表中, 让外面可以使用. 1 2 一样, 都是声明了一个要导出的函数. 3. 定义了一个宏来表示.__declspec(dllexport) 同时, 导出一个类. 使用宏的方式来定义 __declspec(dllexport) 是widnows 下函数库设计的常见方式.
赵4老师 2012-02-20
  • 打赏
  • 举报
回复
查MSDN是Windows程序员必须掌握的技能之一。

Using _declspec(dllexport)
Microsoft introduced __export in the 16-bit compiler version of Visual C++ to allow the compiler to generate the export names automatically and place them in a .LIB file. This .LIB file could then be used just like a static .LIB to link with a DLL.

Microsoft added __declspec(dllexport) to continue this convenience. Its purpose is to add the export directive to the object file so you don't need a .DEF file.

This convenience is most apparent when trying to export decorated C++ function names. There is no standard specification for name decoration, so the name of an exported function may change between compiler versions. If you use __declspec(dllexport), recompiling the DLL and dependent .EXE files is necessary only to account for any naming convention changes.

Many export directives, such as ordinals, NONAME, and PRIVATE, can be made only in a .DEF file, and there is no way to specify these attributes without a .DEF file. However, using __declspec(dllexport) in addition to using a .DEF file does not cause build errors.

ryfdizuo 2012-02-20
  • 打赏
  • 举报
回复
导出函数和导出类。
xunxun 2012-02-20
  • 打赏
  • 举报
回复
这不都一样么

都是导出dll的符号,供其他程序调用
Dobzhansky 2012-02-20
  • 打赏
  • 举报
回复
__declspec(dllexport) 是告诉连接器, 将后面的符号放入导出表中, 让外面可以使用.

1 2 一样, 都是声明了一个要导出的函数.

3. 定义了一个宏来表示.__declspec(dllexport)
同时, 导出一个类.

使用宏的方式来定义 __declspec(dllexport)
是widnows 下函数库设计的常见方式.

jackyjkchen 2012-02-20
  • 打赏
  • 举报
回复
导出函数,生成dll用的

64,652

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧