Advertisement Jump to content
Sign in to follow this  

assert in release

This topic is 4744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How to do assert in release? or something similar? BTW assert(dosomething() ); it is bug, because it will be remove in release. so dosomething() never is call . problem occur in translate from debug to release, I put here for warnning. Are there something else that need to pay attention to in debug to release?

Share this post

Link to post
Share on other sites
Asserts are ment to check some things in debug and NOT IN RELEASE.

Usual someone uses ASSERTS to check if pointers are vaild, if file handles are open, if string sizes are greater than zero and so on.

Asserts help you to control your program, but they also make it slower. Usual someone makes asserts there, where it is critical that a condition is true and for usual it should newer happen.

for example a simle render loop

create device and get a pointer for pMyDevice...
if (pMyDevice == NULL) go out

further more somewhere in program
assert(pMyDevice != NULL); //you do not need that in RELEASE
..render stuff


Share this post

Link to post
Share on other sites
Asserts are just there to help in debugging.

Even so, it isn't unusual to see something like this:
bool foo( void* x ) {
assert( x != 0 && "We can't compute the foo of a void pointer." );
if( 0 == x )
return false;

(Oh, and in case you didn't know about it, you can add 'comments' to assert statements just like I did above to display when the program stops.)

The above command will use the assertion in debug builds, tripping the debugger or otherwise killing the program. In release builds, it will return false since that's the safe way to proceed.

Share this post

Link to post
Share on other sites

In this case DoSomething() will not be executed in Release build. Try one of these options instead:

    return false;


bool bResult = DoSomething();
if (bResult)
    return false;

"VERIFY" is the same as ASSERT, the only difference is that it evaluates the statement also for Release build (without popping up message boxes). As Jack said assertion statements are meant to catch careless mistakes made in Debug build, these assertions should never be fired even if they are in Release build.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!