Sachin Sharma
Thank you for visiting http://sachinssharma.blogspot.com/ X a c h i n
 

What's News?


Only a Sith deals in absolutes. I will do what I must.
- Obi Wan Kanobi
- StarWars III - Revenge of the Sith

 

Microsoft Visual Studio 2005 and C++

I have been following the development of Visual Studio 2005 since a few months before it was released in December 2005. Then I started waiting for our company to receive its own copy of Visual Studio 2005. Finally, we did receive it and soon I got it installed on my computer.

First impression, it has an integrated RSS reader as the start page. In spite of the Start Page, it loads a lot faster than Visual Studio 2003. In Visual Studio 2003, I had disabled the start page to make it load significantly faster. Since I am not a big fan of start pages, I disabling it in 2005 as well. If I find a way to customize the RSS reader, I may turn it back on.

The next thing, I opened one of my older 2003 MFC sample projects and converted it to 2005. An upgrade wizard popped up, which also gave me an option to save a backup. Upon completion, an upgrade report told me what I already knew – secure libraries and better ISO C++ conformance. Fortunately, this does not affect MFC code and upgrading an MFC project is as simple as a quick recompile. However, a project using a lot of C runtime functions and STL requires quite a bit of efforts to upgrade, as I realized later.

Then I started skimming through the menus. I found that there are two good additions in the IDE. The first one is a Code Window. This window displays the definition of the function which is under your caret. The other welcome addition is a “Caller Graph”. Select a function and ask Visual Studio to generate a Caller’s graph for you and it will display all functions from where you have called the function under consideration. This feature also works the other way around. You can get a listing of all functions called from within the function under consideration. This is bound to prove very useful for me. After tinkering around with these features, I realized that some amazing work has been put into making searches a whole lot better than it ever was – very impressive indeed.

Next, I looked into the solution window. This window in VS2005 displays files which are actually present in your hard-drive by toggling the view of the solution. Moreover, if you delete a file from the solution, you will find an option to delete it from your hard-drive too. You will have to go to Windows Explorer only rarely for anything related to your solution (Great!). The class window also has a search feature. Although, I did not look into this feature, you should be able to search your classes, methods and data members in a jiffy. I will try this out later.

Soon I was assigned to upgrade one of our products from VS2003 to VS2005. This product consisted of a legacy COM project that uses a lot of C libraries. I tried my first compile and started receiving hundreds of security deprecation warnings. All C runtime functions like strcpy, strcat, wcstombs, mbstowcs etc. were declared deprecated. The fix was to change over to a secure version of the function that had the same name but with a “_s” appended to it. Every secure function also takes an extra size argument for every buffer you are trying to copy to. Some secure functions take two extra arguments. Nevertheless, I had to see the conversion through. Three full days – that is what it took me to convert this project entirely.

It did baffle me later that while strcpy had to be converted to strcpy_s, the function lstrcpy was kept unchanged. So were other “l” variants of the C runtime functions. All along, I have been using the Unicode aware lstrcpy instead of strcpy and now I have to change even these. That was somewhat of a trouble.

I also read that Microsoft has released Express versions for all languages with full-fledged IDE and language compiler for FREE. Unfortunately for me, Visual C++ Express does not support ATL and MFC – very disappointing. It does compile native Win32 code though; after installing the Platform SDK separately. Anyway, overall, the experience of using Visual Studio 2005 has been exhilarating.
 
Sunday, January 22, 2006 at 2:35 AM. Comments: 0.
Details
Post/View comments
 
 
 
 
 

This page is powered by Blogger. Isn't yours?

 
Copyright © Sachin Sharma. All rights reserved.