SDL breaking asserts in visual studio

This is my first time posting to this list, so if this is a common question
please just point me in the right direction. I tried to find a solution to
my problem on the SDL site and with google, but couldn’t.

Here is my problem: it seems calling a certain SDL method breaks my assert
function/macro from then on.

http://www.AndresBecerra.com/ShackUpload/Files/sdlbreaksasserts.rar
^^^Here is the source code (~20 lines) and a visual studio project that
demonstrates the problem. I think this link will only work for a week or so.

Normally when running in debug mode in visual studio, when you hit an assert
whose expression evaluates to false, a dialog window pops up saying “Oh no!
You’ve hit an assert! etc etc” and you can choose to either debug from the
point of the assert or ignore the assertion, or abort the debugged program.
However, when my asserts fail after calling SDL_SetVideoMode, they no longer
pop up the dialog window, they just abort the debugged program.

Here’s a snippet of source code that hopefully makes it clear how the
problem occurs:
// assert(false); // this will raise an assert dialog if uncommented
SDL_Surface* screen = SDL_SetVideoMode(100, 100, 32, SDL_OPENGL |
SDL_RESIZABLE);
assert(false); // this will not raise a dialog - it aborts the program
being debugged

I’m running windows XP, SDL 1.26, visual studio 7.1.

This may be related: when linking, I get this error:
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib’
conflicts with use of other libs; use /NODEFAULTLIB:library

However, when I add that /NODEFAULTLIB:mscvrt.lib switch to the linker, the
linker error goes away and I still get the same problem with asserts. I set
up the project (with multithreaded debug DLLs) just how the SDL website
explains (you can verify this by looking at the settings in the visual
studio project I have in the zip file linked above).

Here is what I’ve found out about the problem:
To find out what was going on, I’ve stepped deep into the assert code. At
the deepest part of the assert() call-chain, there is a call made to
MessageBoxA (a windows API call). If I call assert(false) before the call to
the SDL function, , then the MessageBoxA invocation makes a message box pop
up.

However, when assert is called after calling the SDL method, assert still
calls the MessageBoxA function, and the function returns immediately without
popping up a dialog, and returns the error code for ABORT, which makes the
debugger leave debug mode. (this is normal behavior except for the fact the
MessageBoxA function is returning without user input!).

Here is the call chain (the same chain occurs whether or not the SDL
function is called):
the assert macro calls _assert, which calls abort, which calls _NMSG_WRITE,
which calls _CrtDbgReport, which calls CrtMessageWindow, which calls
__crtMessageBoxA, which calls MessageBoxA via a function pointer which it
gets from a DLL.

The reason this is such a problem is because I can’t just run my program
until it hits an assert, because the ABORT error code makes the debugger
kill the process that’s being debugged, which means I can’t see what’s
causing the asserts.

Sorry about the super long post. Hopefully this has an easy fix (fingers
crossed).