求救,一个超级怪异的编译问题!

bcc222 2010-11-23 09:56:37
程序如下:

void CMovecountView::ShowWave(CString filel, CString filer,CString files)
{

ClearWave();
Invalidate();
UpdateWindow();
Sleep(2000);
int leftzero=0;
int rightzero=0;
int zeroflagl=0,zeroflagr=0;
int ldata=0;

CFile readfilel;
readfilel.Open(filel,CFile::modeRead);
while(readfilel.Read(&ldata,sizeof(int))==sizeof(int))
{
if(zeroflagl==0&&ldata!=0)
{
leftzero=ldata;
zeroflagl=1;
}
m_leftdatalist.Add(ldata);//-leftzero
}
readfilel.Close();


CFile readfiler;

readfiler.Open(filer,CFile::modeRead);
int rdata=0;

while(readfiler.Read(&rdata,sizeof(int))==sizeof(int))
{
if(zeroflagr==0&&rdata!=0)
{
rightzero=rdata;
zeroflagr=1;
}
m_rightdatalist.Add(rdata);//-rightzero
}
readfiler.Close();

CFile readfiles;
int sdata=0;
readfiles.Open(files,CFile::modeRead);
while(readfiles.Read(&sdata,sizeof(int))==sizeof(int))
{
m_swdatalist.Add(sdata);
}
readfiles.Close();

///////////////////////一直到这里////////////////////////
int a=m_leftdatalist.GetSize();//a==b,值为20000多
int b=m_rightdatalist.GetSize();
int c=m_leftdatalist.GetAt(1);//读取到这个地方出错

}



前面是三段读取文件,这个地方没有问题,然后我读取完文件以后,把文件关闭,开始用carray列表时,加入后面的语句,程序报错,先是提示:afxtempl.h 247 getat()出错,然后再编译文件的时候会出现如下问题,
fatal error C1033: cannot open program database 'e:\带开关轨道衡软件\波形查看与计算-普通\debug\vc60.pdb'

这个时候我只能退出编译程序,删除掉vc60.pdb这个文件,然后重新进行编译,编译可以通过,但是这个地方还是出错

我编译器的setting用的为默认值

原来有一段时间是可以运行的,现在却无法正常编译运行了,请各路高手协助,谢谢



...全文
83 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
bcc222 2010-11-24
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 visualeleven 的回复:]
Debug把流程走一遍
[/Quote]
现在是用debug根本就走不下去,一到打开文件之前就提示getat错误了

[Quote=引用 5 楼 luawkk 的回复:]
好好看看 读取文件部分 msdn
[/Quote]
我看过了,应该不是读取文件的问题,我测试过,把读取文件部分删除掉也会出现这个问题


[Quote=引用 7 楼 ouyh12345 的回复:]
值为20000多
应该是数据量太大了,超出了栈的容量

试试在堆上操作
[/Quote]
我测试了,没有读取文件之前有的时候也出现错误。

估计应该是内存溢出问题,我再看看,等编译出来结果再给大家说!
ouyh12345 2010-11-24
  • 打赏
  • 举报
回复
值为20000多
应该是数据量太大了,超出了栈的容量

试试在堆上操作
Eleven 2010-11-24
  • 打赏
  • 举报
回复
Debug把流程走一遍
luawkk 2010-11-24
  • 打赏
  • 举报
回复
好好看看 读取文件部分 msdn
bcc222 2010-11-24
  • 打赏
  • 举报
回复
现在更离谱了,调试的时候,按动按钮就提示溢出,如果正常的运行就没有问题
bcc222 2010-11-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 flydreamgg 的回复:]
引用 1 楼 bcc222 的回复:
又测试了一下,如果在
int a=m_leftdatalist.GetSize();//a==b,值为20000多
int b=m_rightdatalist.GetSize();

sleep(2000);//增加这个地方

int c=m_leftdatalist.GetAt(1);//读取到这个地方出错

程序可以正常执行,但是还是不能……
[/Quote]

说的有点问题,不是不能编译,是不能调试!一执行调试就提示carray的getat溢出
bcc222 2010-11-24
  • 打赏
  • 举报
回复
First-chance exceptions should always be investigated/explored. You can do the following to get your code to "break" on a first-chance access violation:

-Start debugging your EXE.
-From the "Debug" menu, choose "Exceptions...".
-Find "c0000005 - Access Violation" in the "Exceptions" list box
-Choose "Stop always" in the Action section.
-Click "Change"
-Click OK

Depending on how far your app got by the time you have done this, you may need to restart the debugging session.

When you do, the application will "break" at the first first-chance access violation. Examine the call stack and ensure that everything is as expected. If they aren't, figure out what's wrong. If they are, continue debugging - each first-chance access violation will cause a "break" in the debugger. For each one, make sure that things are as expected. When you have done this, you can change the setting for c0000005 back to "Stop if not handled" in the Debug | Exceptions dialog.

The
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
indicates that DllMain is returning 0. I would suggest getting to the bottom of the access violations before tackling this one, though. The AVs and the failure to initialize the DLL are likely related...
bcc222 2010-11-24
  • 打赏
  • 举报
回复
各位不好意思,经过一下午的奋斗发现问题所在了,我这个程序是想从文件中读取数据,然后画到view中,出现的这个问题不在我贴出来的代码上,而是在OnDraw(CDC* pDC)中,我编译的时候,OnDraw(CDC* pDC)应该另外开了一个线程进行绘图,但是发现数据不正确,所以报错,也就是为什么我在编译的时候,按一下调试就出一个错的原因(程序在刷新页面),我这样理解不知道对不对!


如果避免这个情况的话我找了一个英文的文章看了一下,虽然不明白但是还有点帮助

昨夜无风 2010-11-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bcc222 的回复:]
又测试了一下,如果在
int a=m_leftdatalist.GetSize();//a==b,值为20000多
int b=m_rightdatalist.GetSize();

sleep(2000);//增加这个地方

int c=m_leftdatalist.GetAt(1);//读取到这个地方出错

程序可以正常执行,但是还是不能编译
[/Quote]

都不能编译了,你怎么正常执行的??
bcc222 2010-11-23
  • 打赏
  • 举报
回复
又测试了一下,如果在
int a=m_leftdatalist.GetSize();//a==b,值为20000多
int b=m_rightdatalist.GetSize();

sleep(2000);//增加这个地方

int c=m_leftdatalist.GetAt(1);//读取到这个地方出错

程序可以正常执行,但是还是不能编译

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧