views:

881

answers:

3

I am porting a big and complex c++ server from Solaris to Windows. I am facing lots of trouble due to uninitialized member variables. On Solaris they get set to 0 value by default hence things work fine. But, on windows those member variables get garbage values assigned creating mayhem in the system.

Code base is too huge to manually check each class. Are you aware of any tool or Visual Studio settings that would issue warning if the member variables are not initialized in the constructor?

Thanks in advance!

A: 

You can enable the Code Analysis in Visual Studio (C++ Projects): Project Propertys --> C/C++ --> Enable Code Analysis for C/C++ on build

Baget
Which VS Version are you referring to? I can't find the recommended option in VS2005 :(
Mahendra
You need to get the Platform SDK or buy one of the high-end SKUs. The Platform SDK compiler supports /analyze, which you can pass by the additional command line switch setting.
Anteru
+1  A: 

You can also use an external tool for such task, like PCLint.

Bluebird75
+2  A: 

cppcheck does a very good job at finding uninitialized variables.

Stefan