c++ - 将 DLL 代码从 Borland C++ Builder 6 移植到 Microsoft Visual C

标签 c++ visual-studio-2008 visual-studio-2010 closures c++builder-6

我需要一些来自/用于 DLL 的旧 C++ 代码的帮助,这些代码是用 borland c++ builder 6 编写的,我必须在 VS2008 或 VS2010 中重新编译它。由于我们所有的测试都表明 MSVC 优化代码(速度)比 borland builder 高 4 倍以上...而且我们的软件有一些实时要求。 我用 std 或 win32api 函数重写和/或包装了很多 VCL 代码,主要是 AnsiString、事件、线程、列表的类,所以大部分代码都能编译并运行良好......

但是我遇到了一个我不知道如何单独解决的障碍,所以我请求你提供任何帮助。

我不知道如何实现可以模拟 __closure 关键字的东西。我知道这是 borland c++ builder 特定的关键字,允许程序员使用指向成员函数的通用指针。我知道这在 native c++ 中是不可能的,因为指向成员函数的指针不是常规函数指针,而是类似 member_function_pointer=function_pointer-this 的东西。所以__closure必须保存thismember_function_pointer。但我不知道如何实现这一目标。这也不可能,因为我们代码中的类彼此不认识,这将违反良好的面向对象编程原则的所有原则。

对不起我生疏的英文:S 感谢您的宝贵时间和帮助。

最佳答案

或者std::bindboost::bind应该做的伎俩。另见问题“std::bind a member function to an object pointer”和“boost::bind and class member function”。您可能还想看看 boost::functionstd::function

关于c++ - 将 DLL 代码从 Borland C++ Builder 6 移植到 Microsoft Visual C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5105950/

相关文章:

c++ - 使用 ostream 标志作为详细调试标志

c++ - 使用 C++ 从文件读取到列表

.net - 什么是Visual Studio 2008中的 "Client-only Framework subset"?

c++ - std::map 用于小型稀疏集合

visual-studio - Visual Studio加载项应在哪里存储其设置?

c++ - C/C++ 代码的结果

c++ - Google Mock 在尝试指定返回值时给出编译错误

c# - 如何将 Visual Studio .NET 2008 解决方案转换为 Visual Studio .NET 2005?

c++ - fatal error C1083 : Cannot open include file: 'complex.h' : No such file or directory . .\lapacke\include\lapacke.h

visual-studio-2010 - 即使当前构建未成功,Visual Studio 2010 也会启动代码 - 如何禁用?