Friday, August 9, 2013

A tool for searching for memory leaks



1. Download and install utility from http://vld.codeplex.com  (it's free).
2. In VS invoke dialog Tools -> Options..., select page Projects and Solutions -> VC++ Directories and add 
C:\Program Files (x86)\Visual Leak Detector\include 
to the list of Include files, and 
C:\Program Files (x86)\Visual Leak Detector\lib\Win32
to Library files.
3. Restart Visual Studio.
4. In any project file, add line 
#include "vld.h".
5. Build the project and run from the debugger.
6. After exiting the program, Output window will contain additional information about some (but unfortunately not all) of memory leaks, which makes it easy to locate them.
7. Please don't forget to remove #include "vld.h" before committing :)

by Oleg.B

Convenient way to place TODO into Visual Studio C++ project

Any ideas on the subject?

a. You can write a note on a sticker, put sticker on a wall in your office, then work from home for a couple of days and forget about your TODO.

b. You can write a note in your notebook, then add a couple of pages with other notes and forget your TODO.

c. You can file a Defect Request in ClearQuest (or other project management system) and be buried under bureaucracy process instead of coding. Probably your request would go to other developer and then he or she would do what your don't intend to do.

d. You can add a comment in code like with a small type (extra space or char):
//TODO:   mickhael, replace ch++ with  _tcsinc
then search for "TODO" with "Find-In-Files" and obtain tons of TODO's of the whole team.
Your may search "TODO: mikhael" and find nothing due to typo in the comment.

c. I'd recommend using of #pragma message:
#pragma message("//TODO:   mickhael, replace ch++ with  _tcsinc")  

Wednesday, August 7, 2013

MultiByte, UTF-8 and Chinese Character Set



This is a result of long discussion and research of MultiByte encoding with Olga L. this morning. Keep in mind the following information when processing strings when performing localization to Chinese:
  • Multibyte is used in HyperLynx for localized strings.
  • Multibyte is not related to wide chars (wchar_t, Utf-16) at all, even having 2 bytes per character.
  • Multibyte is not related to Utf-8.
  • In Visual Studio debugger you always see Multibyte characters in case Chinese Simplified locale is selected in Control Panel
  • Multibyte (MBCS, DBCS) is the same as CodePage 936 or GB2312 in case Chinese Simplified locale is selected in Control Panel
  • getchar's _(“Two beer or not to be”) returns Multibyte string.
  • “tchar.h” routines like _tcsclen, _tcsncpy,  etc. deal with Multibyte strings
  • .po files are written in UTF-8 and converted to Multibyte on loading
  • .rc files resources are written in Win1251
  • Chinese .zh-CN.rc resources are written in CP936
  • Some of MFC Windows GUI accepts  Multibyte, some only accept ANSI or wchar_t *
Use this site to understand different encodings better, note that on Chinese locale we deal with CP936 Encoding: http://www.kreativekorp.com/charset/encoding.php