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

 

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