在 Visual C 中使用 pugixml .NET 2010

发布于 2024-11-24 08:09:06 字数 711 浏览 3 评论 0原文

我正在为我的最终项目构建一个 GUI。该项目使用 pugixml 作为 xml 解析器来读取一些数据。一切都在控制台模式下运行。

所以我开始了一个新的Windows窗体项目,并添加了我编写的所有头文件。我设计了我的 GUI 等。当我尝试编译所有内容时,都会编译,但是:

pugixml.cpp(5627): error C2440: 'return' : Cannot conversion from 'System::String ^' to 'const pugi::char_t *' 没有可用的用户定义转换运算符,或者 无法将托管类型转换为非托管类型

以下是错误来源的代码:

const char_t* Convert_number_to_string_special(double value) { #如果已定义(_MSC_VER) ||定义(BORLANDC) if (_finite(value)) 返回 (value == 0) ? PUGIXML_TEXT(“0”):0; if (_isnan(value)) 返回 PUGIXML_TEXT("NaN"); 这条线---->返回 PUGIXML_TEXT("-Infinity") + (值 > 0);

我尝试更改项目的配置,但没有得到任何结果。

有什么线索吗?我将非常感激!

提前致谢!

I am building a GUI for my final project. This project uses pugixml as xml parser for reading some data. Everything works in console mode.

So I started a new windows form project and I added all the headers files I wrote. I desgined my GUI etc. When I try to compile everything compiles but this:

pugixml.cpp(5627): error C2440: 'return' : cannot convert from 'System::String ^' to 'const pugi::char_t *'
No user-defined-conversion operator available, or
Cannot convert a managed type to an unmanaged type

Here is the code where the error comes from:

const char_t* convert_number_to_string_special(double value)
{
#if defined(_MSC_VER) || defined(BORLANDC)
if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0;
if (_isnan(value)) return PUGIXML_TEXT("NaN");
This line----> return PUGIXML_TEXT("-Infinity") + (value > 0);

I tried to change the configuration of the project but I didn't get anything straight.

Any clue? I'd appreciate very much!

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心病无药医 2024-12-01 08:09:06

这是兼容性bug;不幸的是,pugixml 1.0 没有通过 C++/CLI 进行全面测试(据我所知,这是 C++/CLI 的唯一问题,因此修复此问题后您可以安全地使用 pugixml)。

您可以从存储库获取最新版本(http://pugixml.googlecode.com/svn/trunk/)
或手动应用补丁:将行

return PUGIXML_TEXT("-Infinity") + (value > 0);

替换为

return value >; 0 ? PUGIXML_TEXT("无穷大") : PUGIXML_TEXT("-无穷大");

This is the compatibility bug; unfortunately, pugixml 1.0 was not fully tested with C++/CLI (as far as I'm aware, this is the only problem with C++/CLI, so after fixing this you can use pugixml safely).

You can either get the most recent version from the repository (http://pugixml.googlecode.com/svn/trunk/)
or manually apply the patch: replace the line

return PUGIXML_TEXT("-Infinity") + (value > 0);

with

return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文