开发者

Symbol exporting problem using __declspec(dllexport)

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜