Visual Studio输出窗口错误- c++
Visual Studio Output Window Error - C++
使用Visual Studio 2008,我一直在输出窗口看到这个错误:
_CrtDbgReport: String too long or IO Error
我有很多TRACE
宏分散在我的代码中,用于转储有关错误条件的信息:文件路径,行号,错误等。我需要跟踪这个错误的来源,因为它可能是试图转储到输出窗口的信息太长。TRACE
宏可以接受的最大字符串长度是多少?下面是我通常如何使用这个宏的一个示例:
TRACE(_T("CreateNotifyWindow : Failed to create handle for notify window thread.rntError: %drntFile: %srntLine: %drn"), ::GetLastError(), _T(__FILE__), __LINE__);
任何想法都会很感激。谢谢。
最终我敢打赌问题是传递一个对象字符串而不是string.c_str()给宏。TRACE使用可变参数传递,最终,调用vsnprintf()家族中的某些东西进行%s
处理。它不能处理对象,因为C
不能。
OutputDebugString的最大长度是4K字节减去一个分数,由于实现。
你和我遇到了同样的麻烦。我在网上找到了这个问题的答案,然后我检查了一下,效果很好。
// Inside your main header like stdafx.h, add the following include directive
#include <locale.h>
// And inside your main implementation such as InitInstance()
// of your CWinApp derived application class,
// you can put the following locale designation function.
#ifdef _DEBUG
_tsetlocale(LC_ALL, _T("korean")); // you should set the country code of yours
#endif // _DEBUG
现在,您可以在调试输出窗口中看到正确的宽字符串。好运!
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'