从旧的 Borland C++ 迁移 到 Visual C++ 表达

发布于 2024-07-18 07:52:22 字数 632 浏览 2 评论 0原文

冒着显得恐龙的风险,我有一些旧的 C++ 代码,用 Borland C++ 编译,它设置寄存器和汇编器模块的接口,我想对其进行现代化改造。 我刚刚安装了 MS VC++ Express,不用说很多东西都不起作用! 默认值似乎是Win32,这很好,所以我已经空白了FAR和HUGE。 PASCAL 似乎映射到 __stdcall。 所以我有一个宏

 #define THRCOMP  extern "C" int FAR PASCAL _Export

,其中 THRCOMP 位于模块名称前面。 这可能会导致编译器不喜欢的结果

extern "C" int __stdcall _Export <modname>;

,并发出一条有关“不合时宜”的消息(没有说明是什么!)。 怎么了?

另外,旧的代码集有内联汇编器,我需要将其转换为单独编译的子例程 - 是否有(免费)汇编器,并且它可以将汇编器 obj 甲板与 C++ 链接起来吗?

顺便说一句,我看不到我的 obj 组 - 但 WinZip 捡起了它们! 解释?

一般来说,是否有迁移旧 C++ 代码的指南?

提前致谢。

At the risk of appearing a dinosaur, I have some old C++ code, compiled with Borland C++, which sets registers, and interfaces to an Assembler module, which I would like to modernize. I have just installed MS VC++ Express, and needless to say a lot of things don't work! The default seems to be Win32, which is fine, so I have blanked out FAR and HUGE. PASCAL seems to map to __stdcall. So I have a macro

 #define THRCOMP  extern "C" int FAR PASCAL _Export

where THRCOMP goes in front of a module name. This presumably results in something like

extern "C" int __stdcall _Export <modname>;

which the compiler doesn't like, and puts out a message about an "anachronism" (doesn't say what!). What is wrong?

Also the old code sets has in-line Assembler which I need to turn into a separately compiled subroutine - is there a (free) Assembler, and can it link Assembler obj decks in with C++?

By the way, I can't see my obj decks - but WinZip picked them up! Explanation?

Generally, is there a guide to migrating old C++ code?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风无影 2024-07-25 07:52:22

从你的例子中可以看出一些具体的事情:

  • VC根本不喜欢_Export
  • 不合时宜的是,您在数据声明上有修饰符(如 __stdcall)。 如果 没有括号,则它是一个数据声明,并且修饰符不会执行任何操作。 如果 是在汇编中实现的函数,则您仍应让声明包含参数列表。

例如:

extern "C" int __stdcall  modname( int x);

您可以从 Windows 驱动程序工具包 获取免费的汇编程序(WDK - 以前称为 DDK),但如果您当前的代码是使用 Borland 的 TASM 编译器编写的,那么它可能不会使用相同的语法,因此可能需要大量的移植工作。 然而,如果当前的汇编器是 16 位代码,那么无论如何将其移植到 32 位汇编器都需要做大量的工作......

A couple of specific things from your example:

  • VC doesn't like _Export at all.
  • the anachronism is that you have modifiers (like __stdcall) on a data declaration. If <modname> doesn't have parens it's a data declaration and the modifiers don't do anything. If <modname> is a function implemented in assembly, you should still have the declaration include the argument list.

For example:

extern "C" int __stdcall  modname( int x);

You can get a free assembler from the Windows Driver Kit (WDK - what used to be called the DDK), but if you're current code is written using Borland's TASM compiler it might not be using the same syntax so there might be quite a bit of work porting it. However, if the current assembler is 16-bit code, you're going to have a lot of work porting it to 32-bit assembler anyway...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文