<legend id='JI0vg'><style id='JI0vg'><dir id='JI0vg'><q id='JI0vg'></q></dir></style></legend>

    • <bdo id='JI0vg'></bdo><ul id='JI0vg'></ul>

      1. <i id='JI0vg'><tr id='JI0vg'><dt id='JI0vg'><q id='JI0vg'><span id='JI0vg'><b id='JI0vg'><form id='JI0vg'><ins id='JI0vg'></ins><ul id='JI0vg'></ul><sub id='JI0vg'></sub></form><legend id='JI0vg'></legend><bdo id='JI0vg'><pre id='JI0vg'><center id='JI0vg'></center></pre></bdo></b><th id='JI0vg'></th></span></q></dt></tr></i><div id='JI0vg'><tfoot id='JI0vg'></tfoot><dl id='JI0vg'><fieldset id='JI0vg'></fieldset></dl></div>
        <tfoot id='JI0vg'></tfoot>

        <small id='JI0vg'></small><noframes id='JI0vg'>

      2. 使用 extern c 和 dllexport 与模块定义 (msvc++) 进行

        时间:2023-10-06

          <tbody id='fDTyd'></tbody>

          • <bdo id='fDTyd'></bdo><ul id='fDTyd'></ul>
          • <legend id='fDTyd'><style id='fDTyd'><dir id='fDTyd'><q id='fDTyd'></q></dir></style></legend>

            1. <small id='fDTyd'></small><noframes id='fDTyd'>

                  <i id='fDTyd'><tr id='fDTyd'><dt id='fDTyd'><q id='fDTyd'><span id='fDTyd'><b id='fDTyd'><form id='fDTyd'><ins id='fDTyd'></ins><ul id='fDTyd'></ul><sub id='fDTyd'></sub></form><legend id='fDTyd'></legend><bdo id='fDTyd'><pre id='fDTyd'><center id='fDTyd'></center></pre></bdo></b><th id='fDTyd'></th></span></q></dt></tr></i><div id='fDTyd'><tfoot id='fDTyd'></tfoot><dl id='fDTyd'><fieldset id='fDTyd'></fieldset></dl></div>
                • <tfoot id='fDTyd'></tfoot>
                  本文介绍了使用 extern c 和 dllexport 与模块定义 (msvc++) 进行 stdcall 名称修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我试图为 dll 导出一个简单的测试函数,以便与指定调用约定的应用程序(仅供参考:mIRC)一起使用:

                  int __stdcall test_func(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

                  现在,要从应用程序调用它,我将使用 test_func 但我注意到由于名称修改,它并不像我想象的那么简单.

                  通过这里的类似主题,我了解到将 extern "C"__declspec(dllexport) 结合使用是一种消除重整的等效(有点)方法到模块定义 (.def).但是,当使用 extern/dllexport 方法时,我的函数(作为示例)始终是 _test_func@numbers 而 .def 删除了我需要导出到的应用程序所需的所有重整.>

                  谁能解释一下这是为什么?我只是对这两种方法很好奇.谢谢!

                  解决方案

                  dllexport/import 被设计为自己加载回来,而不是使用 GetProcAddress 的旧 C 库.您所看到的重整是所有 Microsoft 编译器长期以来对 __stdcall 函数所做的.最有可能的是,您的目标需要一个 __cdecl 函数,而不是 __stdcall,但如果没有,您将需要使用 .def 文件来专门取消对名称的处理.

                  I was trying to export a simple test function for a dll to work with an application (fyi: mIRC) that specifies the calling convention as:

                  int __stdcall test_func(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
                  

                  Now, to call this from the application, I'd be using test_func but I have noticed due to name mangling it is not as simple as I'd thought.

                  Through similar topics here I have come to the understanding that using extern "C" in combination with __declspec(dllexport) is an equivelant (somewhat) method of removing mangling to module definitions (.def). However, when using the extern/dllexport method my function (as an example) is always _test_func@numbers whereas the .def removed all mangling as required for use with the application i needed to export to.

                  Could someone please explain why this is? I'm just curious about the two methods. Thanks!

                  解决方案

                  dllexport/import are designed to be loaded back by themselves, not an old C library using GetProcAddress. The mangling you have seen is what all Microsoft compilers have done for a long time for __stdcall functions. Most likely, your target either expects a __cdecl function, not __stdcall, but if not, you will need to use a .def file to specifically un-mangle the name.

                  这篇关于使用 extern c 和 dllexport 与模块定义 (msvc++) 进行 stdcall 名称修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在visual studio中设置编译标志/bigobj? 下一篇:VC++ 允许对 STL 容器使用 const 类型.为什么?

                  相关文章

                  最新文章

                  <legend id='ulgjS'><style id='ulgjS'><dir id='ulgjS'><q id='ulgjS'></q></dir></style></legend>

                    1. <i id='ulgjS'><tr id='ulgjS'><dt id='ulgjS'><q id='ulgjS'><span id='ulgjS'><b id='ulgjS'><form id='ulgjS'><ins id='ulgjS'></ins><ul id='ulgjS'></ul><sub id='ulgjS'></sub></form><legend id='ulgjS'></legend><bdo id='ulgjS'><pre id='ulgjS'><center id='ulgjS'></center></pre></bdo></b><th id='ulgjS'></th></span></q></dt></tr></i><div id='ulgjS'><tfoot id='ulgjS'></tfoot><dl id='ulgjS'><fieldset id='ulgjS'></fieldset></dl></div>

                      <small id='ulgjS'></small><noframes id='ulgjS'>

                      • <bdo id='ulgjS'></bdo><ul id='ulgjS'></ul>
                      <tfoot id='ulgjS'></tfoot>