如果使用“System::Threading::ThreadState”,则不会发现已弃用的函数(和其他人!)C++ VS2005/2008

发布于 2024-08-16 20:51:47 字数 1063 浏览 1 评论 0原文

我在 vs2005 和 vs2008 上遇到 c++ 问题... 这是重现问题的方法...

创建一个名为“test”的新(c++)项目(文件|新|项目) 选择“Windows 窗体应用程序”

并将“stdio.h”包含和下面的代码片段添加到 test.cpp 源文件中...... -------------------片段开始--------------------

#include <stdio.h>

 ...

int main(array<System::String ^> ^args)
{
    int i;
    System::Threading::ThreadState state;

    char str[20];
    sprintf (str, "%s", "test string");

...

-------- -----------片段结束--------------------

如果您按照上面的方式编译代码(您必须“buildall”首先),您将收到两个关于“i”和“state”未被引用的警告(没有关于 sprintf 被弃用的警告)。

如果您注释掉“System::Threading :Thread state;”,您将收到一个关于“i”未被引用的警告,以及针对“已弃用”sprintf 语句的另一条警告 (C4996)。...

此问题也会出现在“ System::Windows::Forms::MessageBoxIcon"、"System::Base64FormattingOptions"(也许还有所有“枚举类”类型!)

任何人都知道此处演示的问题的原因和解决方法(我还有其他文件演示了此问题) ..)。 (我在 msdn 上启动了一个线程,但后来找到了这个网站!请参阅下面的链接)

Visual Studio 2005 已停止发出有关已弃用函数的警告

I'm facing an issue with c++ on vs2005 and also vs2008...
here's how you can reproduce the issue....

create a new (c++) project called 'test' (file|new|project)
select "Windows Forms Application"

and add the 'stdio.h' include and the code fragment below into the test.cpp source file.....
-------------------start of snippet--------------------

#include <stdio.h>

 ...

int main(array<System::String ^> ^args)
{
    int i;
    System::Threading::ThreadState state;

    char str[20];
    sprintf (str, "%s", "test string");

...

-------------------end of snippet--------------------

If you compile the code as above (you'll have to 'buildall' first), you'll get two warnings about 'i' and 'state' being unreferenced (nothing about sprintf being deprecated).

If you comment out "System::Threading :Thread state;", you'll get one warning about 'i' being unreferenced and another warning (C4996) for the 'deprecated' sprintf statement....

This issue also occurs for "System::Windows::Forms::MessageBoxIcon", "System::Base64FormattingOptions" (and perhap all 'enum class' types!)

Anyone know of the cause and workaround to the issue demonstrated here ( i have other files that demonstate this issue..). (I had started a thread on msdn, but then found this site! see link below)

Visual Studio 2005 has stopped warning about deprecated functions

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

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

发布评论

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

评论(1

为你拒绝所有暧昧 2024-08-23 20:51:47

这听起来像是您应该向 Microsoft 支持部门提出的问题。

This sounds like an issue you should take to Microsoft support.

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