Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Jan 29, 2003

Handling Release-only Bugs


Sometimes a program crashes or simply misbehaves on release builds. This is very frustrating because usually you have to ship the optimized release version. The most common reason for this phenomenon is that some code is executed in _DEBUG mode only. This can happen if you place some important code inside the #ifdef block:
 
#ifdef _DEBUG
m_nInportantGuy = 0; // oops
#endif

Sometimes, you might have placed code with side effects within an ASSERT or TRACE statement:
TRACE("My file : %s", OpenAndGetFileName());
Since these statements vanish in release build, you will get different behavior. The way to avoid these problems is to pay attention and do the important stuff before calling the TRACE or ASSERT:
 
const char * sFilename = OpenAndGetFilename();
TRACE("My file : %s", sFilename);
Gigi Sayfan
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date