Sorry, one last thing, there is nothing between #include ".\fswinview.h" and #ifdef _DEBUG. I added the ... by mistake.
Printable View
Sorry, one last thing, there is nothing between #include ".\fswinview.h" and #ifdef _DEBUG. I added the ... by mistake.
The stdafx.h header shows the problem. The compiler ignores everything that comes before that include directive. Remove it and turn off precompiled headers in the project options.
It now looks like this:That fixed the compiling, awesome! I didn't need to remove the #include "stdafx.h" or turn off precompiled headers. Thanks CornedBee. But I still get the assertion error during debugging. The problem is caused by something in this section:Code:// FSWinView.cpp : implementation of the CFSWinView class
//
#include "stdafx.h"
#include "FSWin.h"
///////////////////////
//// TEST // TEST /////
#include <iostream> ///
#include <fstream> ///
using namespace std;///
//// TEST // TEST /////
///////////////////////
#include "camera.h"
#include "FSWinDoc.h"
...
Any ideas?Code:// Display contents of "sa" (array of Kelvin temperature values) in the CString object "table".
float HUGEP *a_image;
sa.AccessData((void HUGEP **)&a_image);
for (int x=0 ; x<10 ; x++) // x<10 should be x<w
{
for (int y=0 ; y<10 ; y++) // y<10 should be y<h
{
s.Format("%4.2f ", a_image[w*x+y]);
table += s;
}
s.Format(_T("\n"));
table += s;
}
Get rid of the HUGEP thing. It's a relict from 16-bit Windows. But that's not the actual problem, so what type is sa? Are you sure the loop limits are correct? (The comments hint at a possible problem.) What's the value of w - it is used in the array access, but not in the loop itself, which is a bit weird. Which line exactly causes the assertion? The debugger should be able to tell you that, and also exactly what invalid value (typically) caused it.
"sa" is defined earlier as a COleSafeArray object. It can be seen in the code I posted on page 2 of this thread, and below. Note: "va" is an array of floating point values.I'm pretty sure my loop limits are correct. While I was testing with AfxMessageBox, I set the loops to only display a portion of the array. I added those comments so that I would remember to eventually change them back. Below shows how w and h are defined. When executed, w= 320 and h=240.Code:COleSafeArray sa;
sa.Attach(va);
The exact error message I get is:Code:long w, h;
... ... ...
sa.GetUBound(1, &w);
sa.GetUBound(2, &h);
w++;
h++;
If the debugger tells me more, I don't know where to find it.Quote:
Microsoft Visual C++ Debug Library
Debug Assertion Failed!
Program: ...tor\My Documents\Working Copies\Copy of FSWin\Debug\FSWin.exe
File: f:\vs70builds\3077\vc\MFCATL\ship\atlmfc\include\a fxole.inl
Line: 166
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
I'm a huge dope. I fixed it. I was using the COleSafeArray member "AccessData" without subsequently using "UnaccessData". Once I added that to my code, I was no longer getting the failed assertion.
Thanks for all your help!
Kind regards,
Chunky