0
votes

I am running a simulation and it works fine, but then when I am in the debug mode trying to trace the code, it does not finish running properly.

I know sim works, because when I run it normally, it prints out stuff to the screen at the end of the sim, but in the debug mode it never prints anything...

Any ideas why this could be?

2
Stupid question, but does it hit the printing code if you put a breakpoint there? - Skurmedel
not a stupid question...the answer is NO! But it does print it when I don't run the debugger! Hence my confusion and question - user620189
Does your missing output ever show up in the debugger's output window? - Chris O
The usual difference between debug and release mode is that uninitialized variables happen to get different values. - Bo Persson

2 Answers

0
votes

I am not sure if you are placing the breakpoints there.

Also you may set the DEBUG macros in your code and print out more verbose output when in debug mode.

Here is the simple Macro that you may use:

#ifdef _DEBUG

    ... your code

#endif //_DEBUG

When in Debug mode Visual Studio will execute the lines that are present in between the '_DEBUG' mode.

0
votes

'I know the code works', except when it doesn't. It's perfectly possible to have bugged code which works in one situation but doesn't in another. Forget your assumption that the code is OK, and instead just concentrate on tracking down this bug like you would any other.

Uninitialized variables are the kind of thing that might cause different behaviour in and outside of the debugger, but really it could be anything.