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;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章