Pages

Showing posts with label IDE. Show all posts
Showing posts with label IDE. Show all posts

Tuesday, 9 January 2007

Porting unmanaged C++ code from VS2003 to VS2005

This should normally not cause too much trouble, after all, it's the same language and the same platform. Only the compiler changes a little. The VS2005 compiler does extra checks, especially in the 64bits and security area.

Warning C4244: 'initializing' : conversion from 'INT_PTR' to 'int', possible loss of data

  • Solution: disable Detect 64-bit portability issue in the project options Configuration Properties > C/C++ > General.

Warning C4996: 'sprintf' was declared deprecated

  • Solution: use the new and secure sprintf_s.

Reference: Deprecated CRT Functions

Note: don't use the new secure functions if you intend to keep compiling under VS2003. VS2003 projects will break if the new secure CRT functions are used. To disable the warnings, define _CRT_SECURE_NO_WARNINGS.

Warning C4996: 'itoa' was declared deprecated

  • Solution: replace itoa with _itoa or _itoa_s ...or use a CString (which is more elegant):

Warning C4996: '_fcvt' was declared deprecated

  • Solution: use _fcvt_s or CString.

Warning C4482: nonstandard extension used: enum 'CSecureRst::OperatorTypeEnum' used in qualified name

  • Solution: don't write the name of the enum type when specifying the enum.

Saturday, 30 December 2006

Cool things in Visual Studio 2005

Useful features that do not exist in Visual Studio 2003

  • Code definition window (separate window that shows automatically the definition of the variable currently under the cursor)
  • Find all references command
  • Class view is searchable
  • Class view shows base types and derived types (C++)
  • Class view contains a subpane showing members of current class (makes the tree cleaner)
  • Find in files dialog is modeless (crucial for refactoring) and automatically moves to display the matched string.

New in Visual Studio 2005: http://msdn2.microsoft.com/en-us/library/88fx1xy0(VS.80).aspx