利用Visual C++把代码运行在多平台上(含外文出处)(中文4900字,英文3000字)
摘要:本文简要介绍了VC++在macintosh平台上转换的步骤,及两个平台编程样式、处理器、用户界面的不同,最后通过编译器来达到转换,讲解深入浅出,内容系统全面。
关键字:windows 平台 编译器 API
利用Visual C++把代码运行在多平台上
在今天,多平台的开发是一个热门课题。开发人员希望能够支持不同的平台,例如Windows 3.x, Windows NT, 和 Windows 95 操作系统, 还有Apple, Macintosh, UNIX, 和 RISC (reduced instruction set computer)等。直到不久之前,希望开发多平台任务的开发者们,只有很少的几种选择:
• 根据各个平台的不同的应用程序接口,为每个平台准备一份单独的代码。
• 利用能跨平台的工具所提供的“虚拟API”。
• 构建们自己的多平台层并支持它。
但是到了今天,有了一种新的办法。开发人员可以通过使用微软和第三方的工具,把他们现存的针对Windows API写的代码,对以上列举的各种平台重新编译。本文要关注的就是与这种新办法相关的方法和论点。
目前,Macintosh是紧随Windows之后,市场上最流行的图形用户界面系统。但是这两个完全不同的操作系统之间有太多的不同,需要开发人员学习新的API、新的范例程序、新的工具。一般情况下,对Macintosh应用程序的开发,需要和Windows不同的代码库,这些都增加了维护和升级的复杂度。
From one code base to many platforms using Visual C++
Multiple-platform development is a hot issue today. Developers want to be able to support diverse platforms such as the Microsoft® Windows® version 3.x, Microsoft Windows NT®, and Microsoft Windows 95 operating systems, and Apple®, Macintosh®, UNIX, and RISC (reduced instruction set computer) machines. Until recently, developers wanting to build versions of their application for more than one platform had few choices:
• Maintain separate code bases for each platform, written to the platform's native application programming interface (API).
• Write to a "virtual API" such as those provided by cross-platform toolsets.
• Build their own multiple-platform layer and support it.
Today, however, a new choice exists. Developers can use their existing code written to the Windows API and, using tools available from Microsoft and third parties, recompile for all of the platforms listed above. This paper looks at the methods and some of the issues involved in doing so.
Currently the most lucrative market for graphical user interface (GUI) applications, after Microsoft Windows, is the Apple Macintosh. However, vast differences separate these wholly different operating systems, requiring developers to learn new APIs, programming paradigms, and tools. Generally, Macintosh development requires a separate code base from the Windows sources, increasing the complexity of maintenance and enhancement.
Because porting code from Windows to the Macintosh can be the most difficult porting case, this paper concentrates in this area. In general, if your code base is sufficiently portable to enable straightforward recompiling for the Macintosh (excluding any platform-specific, or "edge" code, you may elect to include), you'll find that it will come up on other platforms easily as well. |