使用 __declspec(dllexport) 的符号导出问题
我将 __declspec(dllexport) 与库中的多种方法一起使用。但其中一个符号无法正确导出。有问题的值称为“重新启动”。我在下面给出了 dumpbin.exe 的输出:
1 0 0002DB27 ev_err = @ILT+2850(_ev_err)
2 1 0002DADC m_foutput = @ILT+2775(_m_foutput)
3 2 0002D361 m_free = @ILT+860(_m_free)
4 3 0002D505 m_free_vars = @ILT+1280(_m_free_vars)
5 4 0002D055 m_get = @ILT+80(_m_get)
6 5 0002D95B m_ident = @ILT+2390(_m_ident)
7 6 0002D80C m_inverse = @ILT+2055(_m_inverse)
8 7 0002D0F5 m_mlt = @ILT+240(_m_mlt)
9 8 0002D339 m_ones = @ILT+820(_m_ones)
10 9 0002D43D m_rand = @ILT+1080(_m_rand)
11 A 0002DC3F m_resize = @ILT+3130(_m_resize)
12 B 0002D465 m_zero = @ILT+1120(_m_zero)
13 C 0002D3A7 px_foutput = @ILT+930(_px_foutput)
14 D 0002DA2D px_free = @ILT+2600(_px_free)
15 E 00092DE0 restart = _restart
16 F 0002DB45 set_err_flag = @ILT+2880(_set_err_flag)
17 10 0002D550 v_foutput = @ILT+1355(_v_foutput)
18 11 0002D839 v_free = @ILT+2100(_v_free)
这似乎表明重新启动没有正确导出,但我不明白为什么。
我使用以下行导出变量:
extern __declspec(dllexport) jmp_buf restart;
此异常的原因是什么以及如何解决它?
I use __declspec(dllexport) with several methods in a library. But one of the symbols do not get exported properly. The value in question is called "restart". I've given the output from dumpbin.exe, below:
1 0 0002DB27 ev_err = @ILT+2850(_ev_err)
2 1 0002DADC m_foutput = @ILT+2775(_m_foutput)
3 2 0002D361 m_free = @ILT+860(_m_free)
4 3 0002D505 m_free_vars = @ILT+1280(_m_free_vars)
5 4 0002D055 m_get = @ILT+80(_m_get)
6 5 0002D95B m_ident = @ILT+2390(_m_ident)
7 6 0002D80C m_inverse = @ILT+2055(_m_inverse)
8 7 0002D0F5 m_mlt = @ILT+240(_m_mlt)
9 8 0002D339 m_ones = @ILT+820(_m_ones)
10 9 0002D43D m_rand = @ILT+1080(_m_rand)
11 A 0002DC3F m_resize = @ILT+3130(_m_resize)
12 B 0002D465 m_zero = @ILT+1120(_m_zero)
13 C 0002D3A7 px_foutput = @ILT+930(_px_foutput)
14 D 0002DA2D px_free = @ILT+2600(_px_free)
15 E 00092DE0 restart = _restart
16 F 0002DB45 set_err_flag = @ILT+2880(_set_err_flag)
17 10 0002D550 v_foutput = @ILT+1355(_v_foutput)
18 11 0002D839 v_free = @ILT+2100(_v_free)
This seems to indicate that restart did not get exported properly but I can't figure out why.
I use the following line to export the variable:
extern __declspec(dllexport) jmp_buf restart;
What is the reason for this anomaly and how can I resolve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为你的“重启”标识符是数据,而不是代码。它可能应该被命名为“restart_state”。从 DLL 导出数据是一种受支持的方案,但却是一个让您大吃一惊的好方法。客户端代码必须与 DLL 代码具有严格的二进制兼容性。对于 setjmp() 来说,这是一个非常值得怀疑的命题,保存的状态高度依赖于实现。
最好导出进行 setjmp() 和 longjmp() 调用并保持 jmp_buf 私有的函数。
It is because your "restart" identifier is data, not code. It probably should have been named "restart_state". Exporting data from a DLL is a supported scenario but a good way to blow your foot off. The client code has to have strict binary compatibility with the DLL code. That's a very questionable proposition for setjmp(), the saved state is highly implementation dependent.
You are much better off exporting functions that make the setjmp() and longjmp() calls and keep the jmp_buf private.
您必须在定义和声明上具有 dllexport 属性。该定义是在其中定义了“restart”而没有“extern”关键字的源文件。
You must have the dllexport attribute on the definition and the declaration. The definition is the source file where you have "restart" defined without the "extern" keyword.