Using Visual C++? Consider These Upgrades

by Dejan Jelovic

If you are programming in Visual C++, consider these great upgrades that will help you write better code.

STLport

The STL that ships with Visual C++ just plainly sucks. Many many many versions ago when it got shipped with the compiler, it sucked. The string corrupted memory. The getline function didn't work. The map and set deadlocked. The auto_ptr that was supposed to help with memory management leaked memory.

I'm using the latest Visual C++ (version 6, service pack 4), and the STL still sucks. For example, try executing the following code:

int main(int argc, char* argv[]) {
    atexit (_CrtDumpMemoryLeaks);

    std::deque<int> intCollection;
    for (int i = 0; i < 512; ++i) {
        intCollection.push_back (i);
    }

    return 0;
}

The compiler output window should greet you with the following text:

Detected memory leaks!
Dumping objects ->
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {44} normal block at 0x002F3B68, 4096 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD 
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {41} normal block at 0x002F2AB8, 33 bytes long.
Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD 
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\crtdbg.h(552) : {40} normal block at 0x002F2A50, 40 bytes long.
Data: < !B > EC 21 42 00 16 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.

(Dinkumware is the company that sold the STL to Microsoft. They have posted a page with fixes for these problems, but my tests show they just make the matters worse.)

Here's a refreshing alternative: STLport.

STLport is a version of STL that kicks ass! First of all, it works in Visual C++. Without a hitch. Second of all, it works. No memory leaks, no corrupted memory, no problems. Third, it is full of asserts. In the debug mode it will catch many problems like when you are using an invalidated iterator.

Not much more to be said about a tool that simply works. Try it out.

Intel C++ Compiler

Since Intel has a love-hate relationship with Microsoft, it has to make sure that its latest processor is fully supported. The way to do that is to produce a a superb compiler that plugs into the Visual C++ environment and compiles all Visual C++ programs, only better.

Let me sum up the Intel C++ compiler in five quick points:

  1. Integrates into the Visual C++ environment
  2. Will compile all your existing VC++ code
  3. Produces faster code than VC++
  4. Compiles templates properly
  5. Produces better error messages

So try it out. There is a 30-day evaluation on Intel's site, and if you like it it's worth dishing $400 for it.

Boost.org

Just like software is in danger of feature creep, so are the standards. The C++ standardization committee had to define a scope, and not add any features outside it. Thus many good things got left out simply because the standard had to get done.

Some of the members of the C++ committee then founded boost.org, as a way to provide standard-quality components that might be useful to C++ programmers at large.

So visit boost.org and download some cool stuff for your compiler.

Smart Pointers

I have developed a set of smart pointers that pretty much eliminate all memory errors. Rather than drivel about their advantages, try reading the original text

 

Read more...


Content of this site is Dejan Jelovic. All rights reserved.