编译遇到个错误

zdk163com 2011-11-01 09:57:16

Assertion failed!
Program:...s\Administrator\..\..\Debug\Dsy.exe
File:E:\..\..\SerialPort.cpp
Line:606
Expression:m_hComm!=0
For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts
中止 重试 忽略


提示的是SerialPort.cpp第606行m_hComm!=0有问题,下面
For information on how your program can cause an assertion failure,see the Visual C++ documentation on asserts
这句是什么意思,有木有遇到过这个问题的,该怎么解决!!!??

...全文
184 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xibinwang 2013-04-13
  • 打赏
  • 举报
回复
我也遇到这种问题了,请大侠你们都怎么解决了?
赵4老师 2011-11-01
  • 打赏
  • 举报
回复
按Alt+7键查看Call Stack里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码处。
nostopstep 2011-11-01
  • 打赏
  • 举报
回复
0XC0000005是空指针了,引起这个问题的一般会是变量没有空间,且未作判断就直接使用,另一种有可能是夹在那个库的时候使用错误的方法。
坏男孩 2011-11-01
  • 打赏
  • 举报
回复
断言错误吧
七擒关羽 2011-11-01
  • 打赏
  • 举报
回复
调用库函数,但是没有包含进来头文件
七擒关羽 2011-11-01
  • 打赏
  • 举报
回复
你的问题应该是头文件缺失
zdk163com 2011-11-01
  • 打赏
  • 举报
回复
这个问题。比较复杂了。。我还是自己研究下吧。~~~~(>_<)~~~~
zdk163com 2011-11-01
  • 打赏
  • 举报
回复

按照大侠的修改,又出现“Unhandled exception in Dsy.exe(MSVCRTD.DLL):0XC0000005:Access Violation.”这个错误!!


[Quote=引用 5 楼 studycbc 的回复:]
C/C++ code

void CSerialPort::WriteToPort(char* string)
{
/*assert(m_hComm != 0);*///断言判断传进来的参数是否有效
assert(string != NULL);
int len = sizeof(*string);//判断传进来字符串长度
char m_szWriteBuffer[len ];//……
[/Quote]
luciferisnotsatan 2011-11-01
  • 打赏
  • 举报
回复
提示的是SerialPort.cpp第606行m_hComm!=0有问题

提示不写的很清楚,断言失败了。自己看看m_hComm的值,为何会导致失败
七擒关羽 2011-11-01
  • 打赏
  • 举报
回复

void CSerialPort::WriteToPort(char* string)
{
/*assert(m_hComm != 0);*///断言判断传进来的参数是否有效
assert(string != NULL);
int len = sizeof(*string);//判断传进来字符串长度
char m_szWriteBuffer[len ];//定义同长度数组
memset(m_szWriteBuffer, 0, sizeof(m_szWriteBuffer));//m_szWriteBuffer没定义
strcpy(m_szWriteBuffer, string);

// set event for write
SetEvent(m_hWriteEvent);//m_hWriteEvent没定义
}



zdk163com 2011-11-01
  • 打赏
  • 举报
回复
我看看。。[Quote=引用 1 楼 zdk163com 的回复:]
void CSerialPort::WriteToPort(char* string)
{
assert(m_hComm != 0);

memset(m_szWriteBuffer, 0, sizeof(m_szWriteBuffer));
strcpy(m_szWriteBuffer, string);

// set event for write
SetEvent(m_hW……
[/Quote]
zdk163com 2011-11-01
  • 打赏
  • 举报
回复
单步执行到Port3.WriteToPort(m_strSendString);弹出了那个错误提示。。!
powtxt 2011-11-01
  • 打赏
  • 举报
回复
m_hComm为0了,没打开端口吧
zdk163com 2011-11-01
  • 打赏
  • 举报
回复
void CSerialPort::WriteToPort(char* string)
{
assert(m_hComm != 0);

memset(m_szWriteBuffer, 0, sizeof(m_szWriteBuffer));
strcpy(m_szWriteBuffer, string);

// set event for write
SetEvent(m_hWriteEvent);
}

是在这个函数里出的问题。

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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