gpt4 book ai didi

c++ - MSVC 警告 4611 关于 setjmp w/POD 结构

转载 作者:太空狗 更新时间:2023-10-29 22:57:14 25 4
gpt4 key购买 nike

尝试在也构建为 C++ 的 C 代码库上提高一些警告级别。我正在试一试 Visual Studio(出于某种原因)。

收到有关 setjmp 交互的警告,尽管没有看到任何相关的析构函数。所以我做了一个测试:

#include <setjmp.h>

struct X { int y; };

int main() {
struct X x;

jmp_buf buf;
if (setjmp(buf) == 0) {
longjmp(buf, 1);
} else {
// whatever.
}
}

在命令行上启用警告:

C:\wherever>cl /we4611 test.cpp

test.cpp test.cpp(9): error C4611: interaction between '_setjmp' and C++ object destruction is non-portable

这似乎是一个非常有用的警告——如果它是在警告我关于交叉 C++ 析构函数代码的话。但那是 POD 类型。不应有任何析构函数代码。

我是不是漏掉了什么,还是他们把这个警告搞砸了,以至于基本上是“你在 C++ 程序中使用了 setjmp”?

最佳答案

did they botch this warning to the point of making it basically "you used setjmp in a C++ program"?

看起来是这样。

我自己可能会将其归类为错误。但是make a suggestion更容易在微软网站上。可以对建议进行投票,那里...

关于c++ - MSVC 警告 4611 关于 setjmp w/POD 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45384718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com