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

      <bdo id='Kauta'></bdo><ul id='Kauta'></ul>
    1. <legend id='Kauta'><style id='Kauta'><dir id='Kauta'><q id='Kauta'></q></dir></style></legend>
    2. <small id='Kauta'></small><noframes id='Kauta'>

      <tfoot id='Kauta'></tfoot>
    3. 使用 extern c 和 dllexport 与模块定义 (msvc++) 进行 stdcall 名称修改

      时间:2023-07-02
        <tbody id='67xiz'></tbody>
        <bdo id='67xiz'></bdo><ul id='67xiz'></ul>
        <i id='67xiz'><tr id='67xiz'><dt id='67xiz'><q id='67xiz'><span id='67xiz'><b id='67xiz'><form id='67xiz'><ins id='67xiz'></ins><ul id='67xiz'></ul><sub id='67xiz'></sub></form><legend id='67xiz'></legend><bdo id='67xiz'><pre id='67xiz'><center id='67xiz'></center></pre></bdo></b><th id='67xiz'></th></span></q></dt></tr></i><div id='67xiz'><tfoot id='67xiz'></tfoot><dl id='67xiz'><fieldset id='67xiz'></fieldset></dl></div>
        <tfoot id='67xiz'></tfoot>

        <small id='67xiz'></small><noframes id='67xiz'>

        <legend id='67xiz'><style id='67xiz'><dir id='67xiz'><q id='67xiz'></q></dir></style></legend>

              • 本文介绍了使用 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 名称修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文章

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

                  <tfoot id='wKxim'></tfoot>

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

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