如何将c/c ++编译为ms-dos .com程序? [英] How to compile c/c++ to ms-dos .com programs?

查看:116
本文介绍了如何将c/c ++编译为ms-dos .com程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GNU GCC编译器中使用Code :: Blocks. 我的问题是:有什么方法可以将c/c ++代码编译为ms-dos 16bit(.com)可执行格式?
我试图设置构建选项并在网上搜索编译器参数,但找不到任何东西.

I use Code::Blocks with GNU GCC Compiler. My question is: is there any way to compile c/c++ code to ms-dos 16bit (.com) executable format?
I tried to set the build options and search the compiler parameters on the net, but i couldn't find anything.

推荐答案

您当然可以将C和/或C ++(一种古老的方言)编译为16位MS-DOS .com文件.您使用Code :: Blocks拥有的编译器/链接器几乎可以肯定不能做到这一点.

You can certainly compile C and/or (an ancient dialect of) C++ to a 16-bit MS-DOS .com file. The compiler/linker you have with Code::Blocks almost certainly can't do that though.

尤其是,至少就我所知,gcc甚至从未尝试过为16位分段内存环境生成代码. gcc至少有一个端口连接到DOS扩展程序( DJGPP ,但它会生成.exe文件,不是.com,而是使用专有的DOS扩展程序以及古代版本的gcc).

In particular, at least to my knowledge, gcc has never even attempted to generate code for a 16-bit, segmented-memory environment. There was at least one port of gcc to a DOS extender (DJGPP, but it produces .exe files, not .com and it uses a proprietary DOS extender along with an ancient version of gcc).

如果确实需要生成.com文件,则有很多选择,但是所有编译器都相当老,因此,特别是对于C ++,它们接受的语言非常有限.

If you really need to generate a .com file, there are quite a few options, but all the compilers are quite old, so especially with respect to C++ the language they accept is quite limited.

注意事项:如前所述,所有这些内容都很老.一般来说,他们接受的C是相当符合标准的C89,但仅适用于相当小的程序(就代码和数据大小而言,这是必不可少的:.com文件基本上限于合计64 KB的数据和代码).他们接受的C ++与任何接近现代的C ++之间的差异要深得多(例如,有些根本不支持模板 ).这里所有提到的一致性都是相对于当时的其他编译器而言的.按照现代标准,它们的一致性始终很糟糕.

Caveat: As already noted, all of these are very old. Generally speaking, the C they accept is reasonably conformant C89, but only for fairly small programs (both in terms of code and data size--of necessity: .com files are basically limited to a combined total of 64Kbytes of data and code). The differences between the C++ they accept and anything even sort of close to modern is much more profound (e.g., some didn't support templates at all). All mention of conformance here is relative to other compilers of the time; by modern standards, their conformance is uniformly terrible.

  1. Microsoft:仅在相当短的时间内出售了用于MS-DOS的C ++编译器-它们进入市场的时间有些晚,然后转移到了相当早就只生成32位Windows可执行文件的编译器.除了语言一致性以外,优化方面的知识也更多.
  2. Borland:Microsoft的镜像.更好的一致性,较差的优化,可能是最后一个放弃MS-DOS市场的方法.他们最近的MS-DOS编译器甚至支持C ++模板(当时还很新).
  3. Watcom:仍可免费下载的其中之一,但没有商业支持.当它是新产品时,通常被认为是最佳的一致性和优化工具之一.
  4. 元软件:当时相当昂贵的选择.我从未使用过它,但是我尊敬的一些人高度认为它是您可以获得的最佳编译器.主要针对嵌入式系统.
  5. Datalight/Zortech/Symantec/Digital Mars:另一个仍正式可用的.有少量但非常忠诚的追随者.我试了一段时间,但没有找到一个令人信服的理由来使它比其他人更喜欢.
  1. Microsoft: Only sold C++ compilers for MS-DOS for a fairly short time--they were somewhat late into the market, and moved out of it to compilers that produced only 32-bit Windows executables fairly early. Known more for optimization than language conformance.
  2. Borland: Mirror image of Microsoft. Better conformance, poorer optimization, probably the last to abandon the MS-DOS market. Their last few compilers for MS-DOS even supported C++ templates (fairly new at the time).
  3. Watcom: one of the few that's still available as a free download, but without commercial support. When it was new, this was generally considered one of the best available for both conformance and optimization.
  4. Metaware: Quite an expensive option at the time. I never used it, but some people I respected highly considered it the best compiler you could get. Mostly targeted embedded systems.
  5. Datalight/Zortech/Symantec/Digital Mars: the other one that's still officially available. Had a small but extremely loyal following. I tried it for a while, but never found a compelling reason to prefer it to others.

那时也还有很多,但是这些可能在当时占据了90%以上的市场.

There were quite a few more back then as well, but these probably account for well over 90% of the market at the time.

这篇关于如何将c/c ++编译为ms-dos .com程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆