Re: Bug in my C++ program seems really strange. (Update on debugging progress)
mike3 <mike4ty4@yahoo.com> wrote in message...
On Sep 1, 12:57 am, "Alf P. Steinbach" <al...@start.no> wrote:
Changes to make it /compile/:
fracalg\computefrac.cpp(371):#if 0 file://APS
fracalg\computefrac.cpp(378):#endif file://APS
fracalg\computefrac.cpp(393):#if 0 file://APS
fracalg\computefrac.cpp(396):#else file://APS
Excuse me, why all this? Those were commented
out for debugging purposes to help minimalize
the code.
Then they should have been removed for posting. I would be pissed if I spent
good money to download it with my slow dial-up.
render\render.cpp(51): file://APS MessageBox(NULL, TEXT("Zorg."),
TEXT(""), MB_OK);
render\render.cpp(69): file://APS MessageBox(NULL, TEXT("Borg."),
TEXT(""), MB_OK);
Why couldn't it compile with those in?
It's windows code. GNU don't play that!
win32\CMainWnd.cpp(52): wcx.hCursor = LoadCursor(0,
IDC_ARROW); file://APS LoadCursor((HANDLE)NULL, IDC_ARROW); /* cursor */
win32\fg3dImageWindow.cpp(34): wcx.hCursor =
LoadCursor(0,IDC_ARROW); file://APS file://LoadCursor((HANDLE)NULL,
IDC_ARROW); /*
cursor */
win32\fg3dNewImageWzrd.cpp(18)://APS HWND gTmp;
win32\fg3dNewImageWzrd.cpp(32)://APS gTmp = hwndTmp;
main.h(108)://APS extern HWND gTmp;
fracgen3d.cpp(79):// APS
Plus, the WinMain function must be changed to something like
int WINAPI WinMain(HINSTANCE TheInstance, HINSTANCE LastInstance,
LPSTR lpszCmdLine, int iCmdShow){
__try{
return cppWinMain( TheInstance, LastInstance, lpszCmdLine,
iCmdShow );
}
__except(TRUE){
TCHAR szBuf[256];
StringCchPrintf(szBuf, 256, TEXT("EXCEPTION %08lX"),
GetExceptionCode());
OutputDebugString(szBuf);
return 0;
}
}
where cppWinMain contains the original code for that __try.
It's funny (is that the right word?) when the code contains C style
casts that makes it not compile, when all that's needed is to remove
those casts...
I must be using a really crappy C++ compiler then as
it allows that stuff.
Then set it up for standard compliance, and raise the warning levels.
So then it casts it automatically, you don't need all
that C-style stuff, then? Darn I'm too paranoid.
If you must, use the C++ casts so you get the proper warnings/errors.
Having done all the above the program crashes on using an invalid
pointer txtrptr in [render.cpp] at line 62, which is due to using an
uninitialized member "d3dlr" (presumably there should have been an
earlier call to FractalImage::LockRectangle, but no such).
That is uninitialized? It calls LockRectangle() right
in there @ line 46.
Did you check whether the pointer is valid during/after the 'call'?
If nothing else, try something like:
std::cout<<"pointer addr="<<pointer<<" calling:"<<*pointer;
If the pointer is invalid, that should cause a 'crash'. Then you'll know.
I've run into trouble in my own "spaghetti" code. Now days I separate the
GUI interface, C++ interface, and the work-horse code. Makes it much easier
to track problems, port to another OS, etc.. ( even wxWidgets needs some
'tweaking' between windows and GNU (GTK), but the underlying std C++ code
stays the same.)
--
Bob R
POVrookie