error: non-const static data member must be initialized out of line

编译electron报错:

In file included from ../../electron/shell/browser/api/atom_api_web_contents.h:33:
../../third_party/webrtc/pc/rtp_sender.h:187:32: error: non-const static data member must be initialized out of line

解决:

将非const类型的静态变量拿到类外去初始化。

例子:

// 错误定义方式
class Test {
    int a;
    const int b = 1;
    static int c = 2;//wrong
}

// 正确定义方式
static int c = 2;
class Test {
    int a;
    const int b = 1;
}

猜你喜欢

转载自blog.csdn.net/liuzehn/article/details/106254432