小编bou*_*ika的帖子

不一致的警告:变量可能被'longjmp'或'vfork'破坏

我大多说服自己,我遇到了一些g ++ 4.8.3错误,但我想我会首先问这个列表,因为我对setjmp/longjmp的经验很少.我将我的代码简化为以下foo.cxx:

#include <setjmp.h>
#include <string.h>

// Changing MyStruct to be just a single int makes the compiler happy.
struct MyStruct
{
    int a;
    int b;
};

// Setting MyType to int makes the compiler happy.
#ifdef USE_STRUCT
typedef MyStruct MyType;
#elif USE_INT
typedef int MyType;
#endif

void SomeFunc(MyType val)
{
}

static void static_func(MyType val)
{
    SomeFunc(val);
}

int main(int argc, char **argv)
{
    jmp_buf env;
    if (setjmp(env))
    {
        return 1;
    }

    MyType val;
#ifdef USE_STRUCT
    val.a = …
Run Code Online (Sandbox Code Playgroud)

c++ longjmp setjmp g++4.8

7
推荐指数
1
解决办法
2799
查看次数

标签 统计

c++ ×1

g++4.8 ×1

longjmp ×1

setjmp ×1