Sunday 20 November 2011

When should a 32-bit compiler be used? in C programming

When should a 32-bit compiler be used?

A 32-bit compiler should be used on a 32-bit operating system. The 32-bit compiler creates 32-bit programs
that run your PC much faster than 16-bit programs—which is why 32-bit anything is hot.

With all the different versions of Microsoft Windows out there, which compiler is best for which operating system? This passage looks at what Microsoft offers, and assigns the correct compiler to the correct operating

system. Windows 3.1 and Windows for Workgroups 3.11 are 16-bit operating systems; Microsoft VisualC++ 1.x is a 16-bit compiler. The compiler produces code that will run on Windows 3.1. Microsoft Windows NT and Windows 95 are 32-bit operating systems; Visual C++ 2.0, the latest compiler from Microsoft, is a 32-bit compiler created to produce 32-bit code for these operating systems. The 16-bit programs that Visual 1.x produces will run on Windows NT and Windows 95 as well as Windows 3.1. 

The opposite is not true, however—32-bit code produced by Visual 2.0 will not run on Windows 3.1. Thisfact presents a problem for Microsoft, which wants everyone to use its 32-bit compiler but has 60 million PCs out there running a version of Windows that can’t run these new 32-bit programs. To get around thisobstacle, Microsoft created a translation library called Win32s that performs the 32- to 16-bit “thunking,”as it is called, to allow 32-bit programs produced by Visual C++ 2.0 to run on Windows 3.1 and Windows for Workgroups. Win32s is specifically designed to run on Windows 3.1 (and WFW)—it is not meant for
Windows 95 and NT because they do not need to “thunk” to run 32-bit code. Using Win32s, it is possible
to produce a single program using Visual C++ 2.0 that will run on Windows 3.1 (and WFW) as well as
Windows NT. 

The only remaining gotcha is the compilers themselves. Visual C++ 1.x is a 16-bit Windows program—it will run on Windows 95 and NT and will produce the same 16-bit program as if it were running on Windows 3.1. However, Visual C++ 2.0, being a 32-bit Windows program, will not run on Windows 3.1. It won’t even run if you install Win32s, because Microsoft conveniently makes sure you are running Windows 95or NT before Visual 2.0 will start.To summarize, run Visual C++ 1.x (version 1.51 is the latest) on Windows 3.1, Windows for Workgroups, Windows NT, or Windows 95 to create 16-bit programs that will run on all versions of Windows; run Visual C++ 2.0 to create 32-bit programs that will run fastest on Windows 95 and NT but will also run very well on Windows 3.1 (and WFW).

For you Borland C/C++ users, Borland’s Turbo C++ Version 3.1 is the latest 16-bit compiler, and Borland
C++ Version 4.5 is the 32-bit Windows compiler (note that the 32-bit compiler doesn’t have the “Turbo” moniker). Both compilers contain the compiler, Borland’s OWL C++ classes, and an excellent integrated debugger.

Cross Reference:

None.

No comments:

Post a Comment