Click here to Skip to main content
15,891,607 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 10:07
krsmichael27-Apr-12 10:07 
GeneralRe: Thats why i hate c++ Pin
Gerry Schmitz27-Apr-12 12:02
mveGerry Schmitz27-Apr-12 12:02 
GeneralRe: Thats why i hate c++ Pin
krsmichael27-Apr-12 14:34
krsmichael27-Apr-12 14:34 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 7:32
CDP180227-Apr-12 7:32 
GeneralRe: Thats why i hate c++ Pin
Vasily Tserekh27-Apr-12 7:51
Vasily Tserekh27-Apr-12 7:51 
GeneralRe: Thats why i hate c++ Pin
CDP180227-Apr-12 8:36
CDP180227-Apr-12 8:36 
GeneralRe: Thats why i hate c++ Pin
Al_Brown29-Apr-12 20:59
Al_Brown29-Apr-12 20:59 
GeneralRe: Thats why i hate c++ Pin
patbob27-Apr-12 12:28
patbob27-Apr-12 12:28 
Situations like those are when I usually pull down the OS symbols and install them. Break the app in the debugger while the errant error dialog is being displayed and look at the stack trace. One can't necessarily debug the OS code with the symbols, but they allow an accurate stack trace report to be generated by the debugger. NT's function names are remarkably informative. Between the function names and google, and I can often get a pretty good clue about what the OS is trying to do on my behalf. Occasionally, when I'm really lucky, I can even look at the parameter values being passed (when the deubgger deigns to report them) and start to figure out what's wrong.

Then, there's always printf's. Or the GUI equivalant, MessageBox() calls. Make them unique and try to bracket the line of your code that's causing the error. And the best part, no debugger is required -- you can even debug fully optimized production code if you have to (how else does one find an optimizer bug?).

Or you can do as suggested, comment out blocks of code in a sort of binary search for the troublesome line... although I find that a lot harder to do in practice than the above techniques.
We can program with only 1's, but if all you've got are zeros, you've got nothing.

GeneralRe: Thats why i hate c++ Pin
KP Lee27-Apr-12 13:26
KP Lee27-Apr-12 13:26 
GeneralRe: Thats why i hate c++ Pin
Member 869706828-Apr-12 9:01
professionalMember 869706828-Apr-12 9:01 
GeneralRe: Thats why i hate c++ Pin
mandyedi28-Apr-12 9:03
mandyedi28-Apr-12 9:03 
GeneralRe: Thats why i hate c++ Pin
Charles Oppermann27-Apr-12 2:34
Charles Oppermann27-Apr-12 2:34 
GeneralRe: Thats why i hate c++ Pin
KP Lee27-Apr-12 13:46
KP Lee27-Apr-12 13:46 
GeneralRe: Thats why i hate c++ PinPopular
OriginalGriff24-Apr-12 9:20
mveOriginalGriff24-Apr-12 9:20 
GeneralRe: Thats why i hate c++ Pin
jeron124-Apr-12 10:15
jeron124-Apr-12 10:15 
GeneralRe: Thats why i hate c++ Pin
CDP180224-Apr-12 10:51
CDP180224-Apr-12 10:51 
GeneralRe: Thats why i hate c++ Pin
KP Lee27-Apr-12 14:24
KP Lee27-Apr-12 14:24 
GeneralRe: Thats why i hate c++ Pin
Jörgen Andersson24-Apr-12 11:42
professionalJörgen Andersson24-Apr-12 11:42 
GeneralRe: Thats why i hate c++ Pin
Gary Huck27-Apr-12 3:45
Gary Huck27-Apr-12 3:45 
GeneralRe: Thats why i hate c++ Pin
Mohibur Rashid24-Apr-12 17:28
professionalMohibur Rashid24-Apr-12 17:28 
GeneralRe: Thats why i hate c++ Pin
CDP180225-Apr-12 4:06
CDP180225-Apr-12 4:06 
GeneralRe: Thats why i hate c++ Pin
Mohibur Rashid25-Apr-12 4:34
professionalMohibur Rashid25-Apr-12 4:34 
GeneralRe: Thats why i hate c++ Pin
CDP180226-Apr-12 21:23
CDP180226-Apr-12 21:23 
GeneralRe: Thats why i hate c++ Pin
Mike Winiberg26-Apr-12 20:49
professionalMike Winiberg26-Apr-12 20:49 
GeneralRe: Thats why i hate c++ Pin
Michael Kingsford Gray27-Apr-12 2:45
Michael Kingsford Gray27-Apr-12 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.