Search This Blog

Friday, March 13, 2009

Debugging Tips

While debugging some times we use message box or write in a file.
But we may forget to remove that. To avoid such thing we can use _DEBUG macro to make statements execute only in debug mode not in release mode.

Example:
# ifdef _DEBUG
CStdioFile csTempFile;
if( csTempFile.Open("d:\\temp.txt",CFile::modeCreate|CFile::modeWrite) )
csTempFile.Write(csContents.GetBuffer(csContents.GetLength()+1 ),csContents.GetLength());
csTempFile.Close();
#endif


# ifdef _DEBUG
AfxMessageBox(csContent);
#endif

No comments: