c外文翻译--利用visualc把代码运行在多平台上(编辑修改稿)内容摘要:

lines above will make your code a lot more portable. However, if you have 16bit Windows code, your first step is to make it work properly under Win32. This will require additional changes in your sources. Code written for Win32 can run on any version of Windows, including on the Macintosh, using the portability library. Portable code should pile and execute properly on any platform. Of course, if you use APIs that only function under Windows NT, they will not work when your application runs under Windows . For example, threads work under Windows NT but not under Windows . Those types of functionality differences will have to be accounted for in the design of your application. Chief among the differences between Win16 and Win32 is linear addressing. That means pointers are now 32 bits wide and the keywords near and far are no longer supported. It also means code that assumes segmented memory will break under Win32. In addition to pointers, handles and graphic coordinates are now 32 bits. will resolve many of these size differences for you, but some work is still necessary. The remended strategy to get your application running under Win32 is to repile for 32 bits, noting error messages and warnings. Next, replace plex procedures and assembly language routines with stub procedures. Then, make your main program work properly using the techniques above. Finally, replace each stubbedout procedure with a portable version. After you successfully convert your Windowsbased program from 16 bits to 32 bits, you39。 re ready to embark on porting it to the Macintosh. Because significant differences exist between the two platforms, this task can appear daunting. Before you can begin to port your application, you need to better understand these differences. The Macintosh is differentiated from Windows in three general areas:  Programming model differences  Processor differences  User interface (UI) differences These areas of difference are described below. Porting issues that acpany these differences are discussed in the section titled Porting from Win32 to the Macintosh. The Windows and Macintosh APIs are pletely different. For example:  The event models are different. In Windows, you dispatch messages to WindowProcs. You use DefWindowProc to handle messages in which you39。 re not specifically interested. On the Macintosh, you have a big main event loop to handle all possible events.  Windows uses the concept of child windows. The Macintosh uses no child windows.  Windowsbased applications can draw using either pens or brushes. Macintosh applications can use only pens.  Controls in Windows are builtin window classes. On the Macintosh, controls are unrelated to windows.  Windows allows for 256 binary raster operations。 the Macintosh allows for only 16. Because of the differences between the two platforms, porting a Windowsbased application to the Macintosh can be monumental task without powerful tools. Windows has always run on Intel x86 processors (until Windows NT), and the Macintosh has run on Motorola 680x0 processors (of course, the PowerPCbased Macintosh is now available as well). Differences between the processor families include addressing and byte ordering, in addition to the more expected differences like opcodes, instruction sets, and the name and number of registers. The Intel 8086 processor, from which subsequent 80x86 processors are descended, used 16bit addresses, which unfortunately allowed only 65,536 bytes of memory to be addressed. To allow the use of more memory, Intel implemented a segmented memory architecture to address one megabyte (2^20 bytes) of memory that used an unsigned 16bit segment register and an unsigned 16bit offset. This original Intel scheme has been extended to allow much larger amounts of memory to be addressed, but most existing Intelbased programming relies on separating code and data into 64K segments. Although all Intel x86 processors since the 80386 have used 32bit addressing, for patibility reasons Microsoft Windows is actually a 16bit application, and all Microsoft Windowsbased applications had to be written as 16bit applications. That meant, for example, that most pointers and handles were 16 bits wide. With the advent of Microsoft Windows NT, which is a true 32bit operating system, all native applications are 32bit applications, which means that pointers and handles are 32 bits wide. Because Windows NT uses linear addressing, programs can share up to 4 gigabytes of memory. In contrast, the Motorola 68000 and PowerPC processor have always provided the ability to address a flat 32bit memory space. In theory, a flat memory space of this kind simplifies memory addressing. In practice, because 4byte addresses are too large to use all the time, Macintosh code is generally divided into segments no larger than 32K. Microsoft Windows and Windows NT run only on socalled littleendian machines—processors that place the least significant byte first and the most significant byte last. In contrast, the Motorola 680x0 and PowerPC (a socalled bigendian architecture) place the most significant byte first, followed by the next most significant byte, and so on, with the least significant byte last. Compilers normally handle all details of byte ordering for your application program. Nevertheless, wellwritten portab。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。