在 Windows CE 6.0/Windows Mobile/Windows Embedded Compact 下使用 RapidXml 出现奇怪的异常
当尝试在使用 Visual Studio 2005 编译的 Windows CE 6.0 下运行 RapidXml 1.13 时,我遇到了一个非常奇怪的问题。我有一个非常小的程序无法运行:
#include <rapidxml.hpp>
using namespace rapidxml;
int _tmain(int argc, _TCHAR* argv[])
{
xml_document<char> doc;
return 0;
}
它编译良好,有 0 个错误和 0 个警告(在 W3)。但是,当我运行或调试程序时,出现访问冲突异常:
RapidXml_Test.exe 中 0x000110d4 处的首次机会异常: 0xC0000005:访问冲突写入位置0x0001fb48。
然后调试器将这一行(rapidxml.hpp 中的 1366)指向罪魁祸首(左大括号):
template<class Ch = char>
class xml_document: public xml_node<Ch>, public memory_pool<Ch>
{
public:
//! Constructs empty XML document
xml_document()
: xml_node<Ch>(node_document)
------->{
}
...
如果有人知道问题可能是什么,我将不胜感激。我的构建和运行时环境中有更复杂的代码,所以我不怀疑那里有什么。我也相当有信心这不是一个项目设置。我认为此时 RapidXml 对模板的使用在某种程度上使 Windows CE VC++ 编译器感到困惑。我不知道还可能是什么。
提前致谢!
I'm having a very strange problem when trying to run RapidXml 1.13 under Windows CE 6.0 compiled with Visual Studio 2005. I have an extremely small program that fails to run:
#include <rapidxml.hpp>
using namespace rapidxml;
int _tmain(int argc, _TCHAR* argv[])
{
xml_document<char> doc;
return 0;
}
It compiles fine with 0 errors and 0 warnings (at W3). However, when I run or debug the program, I get an access violation exception:
First-chance exception at 0x000110d4 in RapidXml_Test.exe:
0xC0000005: Access violation writing location 0x0001fb48.
The debugger then points to this line (1366 in rapidxml.hpp) as the culprit (the open brace):
template<class Ch = char>
class xml_document: public xml_node<Ch>, public memory_pool<Ch>
{
public:
//! Constructs empty XML document
xml_document()
: xml_node<Ch>(node_document)
------->{
}
...
If anyone has any clue what the problem could be I'd greatly appreciate it. I have much more complicated code working in my build and run-time environment so I don't suspect anything there. I'm also fairly confident it's not a project setting. I assume at this point that RapidXml's use of templates is somehow confusing the Windows CE VC++ compiler. I don't know what else it could be.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。 RapidXML 加载后会分配自己的内存池。问题是,我认为它在堆栈上分配它,并且我遇到了堆栈溢出! (多么偶然,我的第一个问题实际上是堆栈溢出)。无论如何,减小池的大小解决了我的问题。
I found the solution. RapidXML allocates its own pool of memory once its loaded. Problem is, I think it allocates it on the stack and I was getting a stack overflow! (How serendipitous that the problem with my first question here actually WAS a stack overflow). Anyways, reducing the size of the pool solved my problem.