如果使用“System::Threading::ThreadState”,则不会发现已弃用的函数(和其他人!)C++ VS2005/2008
我在 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 上启动了一个线程,但后来找到了这个网站!请参阅下面的链接)
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来像是您应该向 Microsoft 支持部门提出的问题。
This sounds like an issue you should take to Microsoft support.