「功能」 : 无法从“double”转换到“wchar_t *”

发布于 2024-12-25 19:22:54 字数 758 浏览 3 评论 0原文

我正在尝试在 Visual Studio 2010 中进行编译,这正是我得到的错误:

Error 65 error C2440: 'function' :
       cannot convert from 'double' to 'const wchar_t *'    

违规行是:

swprintf(subbuf[num], L"%f\0", va_arg(args, double));

This is Should to compile cleanly so codechanges not suggest. 我是否缺少任何可以解决此问题的编译器选项?

编辑:

这是subbuf的声明:

#define GDB_CHAR wchar_t
GDB_CHAR subbuf[MAX_SUBS][STATUS_MSG_LEN+1] ;

另外,关于大小参数,我还检查了文档页面,但是,编译器 不会抛出错误,

swprintf(subbuf[num], L"%c\0", va_arg(args, int));

因此从 int 转换为 wchar_t * 时没有问题,并且函数的参数也正常。

如果这仍然不够丰富,请发表评论并指导我找到你们需要的任何其他信息。 谢谢

I am trying to compile in visual studio 2010, and this is the exact error I get:

Error 65 error C2440: 'function' :
       cannot convert from 'double' to 'const wchar_t *'    

The offending line being:

swprintf(subbuf[num], L"%f\0", va_arg(args, double));

This is supposed to compile cleanly so code changes are not recommended.
Am I missing any compiler option which might resolve this?

EDIT:

Here is the declaration of subbuf:

#define GDB_CHAR wchar_t
GDB_CHAR subbuf[MAX_SUBS][STATUS_MSG_LEN+1] ;

Also, regarding the size argument, I also checked the documentation page, however, compiler
doesn't throw an error on

swprintf(subbuf[num], L"%c\0", va_arg(args, int));

So it has no issues in converting from int to wchar_t * and the function's arguments are ok.

If this is still not informative enough, please comment and direct me to any other you guys need.
Thanks

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

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

发布评论

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

评论(1

凉风有信 2025-01-01 19:22:54

快速浏览一下文档表明该函数需要一个参数来指定输出字符串的大小,您已省略。

A quick glance at the documentation shows that the function requires an argument specifying the size of the output string, which you have omitted.

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