Sunday, September 19, 2010

Windows 7 and the Inevitble Headache of 32-bit C++

Windows 7 is here,
Windows 7 is the future,
Windows 7 doesnt support my C++!!!!!

TurboC is definitely functional but NOT COMPLETELY. This is alarming, but most conventional compilors and IDE's that worked on the traditional 16-bit environment will not work anymore, atleast not properly. The more advanced the OS becomes, the more detached it becomes from its roots, or so is the trend these days...


This means we cant use the good old c++ we learnt in school anymore, as the current IDE's that are based on 32-bit systems use Mingw Compilor or Minimalist GNU for Windows. These are some problems you will encounter.. 

★ Mingw doesnt support many headers that we would be familiar with, like conio.h, graphics.h, stdio.h. Instead, trimmed versions may be available of conio and stdio depending on where you downloaded it from.
REASON - Well all these headers (and more) are implementations by Borland and are not required to be present on every Compilor we see, virtually sending us in Coder's Hell.
SOLUTION - It took me 30 minutes to search for a Mingw-compatible conio header that was complete. Same effort was required to find graphics libraries similar to what we used in TurboC++. A good alternative was the Devpak called WinBGIm.

★ Another problem is the "iostream" header file, firstly, you cant refer to any variables like cin or cout just like that, they throw errors as if they were never there(declared).
REASON - C++ namespaces allows us to group a set of global classes, objects and/or functions under a name. Namespace std contains all the classes, objects and functions of the standard C++ library. Borland allowed users to write code with Borland specific libraries without mentioning namespaces but now this habbit will have to change for good.
SOLUTION - Learn to live with it. Either use std:: everywhere or specify to the compiler that you are using namespace 'std', as given in the following code...
#include <iostream>
using namespace std;
int main()
{
      cout << "Hello";
      return 0;
}

 Another problem that needs a special mention..."GRAPHICS"!!!, its different from what most coders have done, although it retains many functions from the original "graphics.h", so do read the documentation on WinBGIm before venturing any further.

Besides these there will be minor adjustment  and coding issues for those who were used to TurboC.