Click to See Complete Forum and Search --> : Sending Messages: Works in debug, fails in release


sshelton
May 3rd, 1999, 07:13 PM
I have code which manually sends messages to parent windows with the SendMessage() function.

Everyone is happy when compiled in debug mode, but when compiled in release mode, they complain and throw fatal errors.

The messages causing the trouble were manually entered and use a message defined in the code. These are not the built in messages like WM_MOUSEMOVE, they're totally created in my program.

The actual function gets called, the explosion seems to happen after the function call. And it's probably not something totally unrelated, because the problem occurred a couple times in different places.

I tried increasing the numeric value of the message without luck. I don't understand why this would fail on release but succeed on debug!

I have worked around these bugs though, mostly I'm just curious to know why it's failing.

Roland Seibert
May 4th, 1999, 01:58 AM
I don't know whether it works in debug and not in release mode. But i think you should guarantee that your message (UM_MESSAGE) is defined above WM_USER as follow:
#define UM_MESSAGE (WM_USER + 1)
so there will be no conflict with windows messages

Hope this helps

Jason Teagle
May 4th, 1999, 02:31 AM
Bear in mind that controls (list boxes, edit boxes, etc.) ALSO use (WM_USER + n) for their special messages (LB_DIR, EN_CHANGE, etc.). Well done, Microsoft. Not.

I recommend (WM_USER + 100) minimum.

What error messages do you get in release mode? It probably works in debug mode better because debug mode makes more allowances and tries to be more robust and thorough in its checking - but you're right, it should work the same in both.

Paul McKenzie
May 4th, 1999, 12:04 PM
The dreaded "debug works, release fails" scenario. Well the way to debug the release build is to go into the Project Settings for the Release build, choose the C++ tab, and select for Debug Info "Program Database".

You'll notice that when you first see the Debug Info combo, it's set to "None". By setting it to Program Database, and setting the "Link" setting to include the Debug Info, you can debug the release build. There is no need to hunt and peck to find the bugs in a release build when just changing the settings and recompiling will allow you to generate symbols and line number info. You can then use the debugger to figure out what went wrong.

You may also want to turn off the optimizations on the first run. It gets weird when you're trying to set a breakpoint or single-stepping through optimized code and lines of code are not being executed.

Regards,

Paul McKenzie