Thursday, July 30, 2009

Differences between the various C++ compliers?

I would like to the difference between the various C++ compilers. I have tried GCC, trubo C++ and sometimes a code working perfectly in one complier does not work in another. Why is that? Which is a good complier? Is there no standard in C++?

Differences between the various C++ compliers?
There are a number places in the C++ spec that say that the method of implementation is left up to the designer of the compiler as long as they meet certain requirement.





For example, the rules require that the storage size of a long be at least as large as that for an int.


Microsoft C++ makes both ints and longs 32 bits. A program that works with 32 bit longs could very easily fail with 16 bit longs and vice versa.





It's also possible that you are breaking a rule that you can get away with on with one compiler, but not the other. For example, if you are running a program built with MS C++ using debug heap allocation, when you free the memory, it gets overwritten with a specific pattern to aid in debugging. If you use a stale pointer, you'll be pointing to trash. The same code built using another compiler might still find valid values in the memory, even though you released it.
Reply:A particular compiler works only on specific platform. So, check the compatibility of the compiler before installing it.


No comments:

Post a Comment