2017年12月29日 星期五

[筆記] 將openair-cn code從C改成C++遇到的error

1. Unknown type name 'class'
該.h同時被.cpp和.c include
因此編譯器會看不懂
Sol:
通通改成.c/.cpp

2. Jump to case label.
因為變數宣告在switch內的某個case
因為在該case以下的部分也看的到該變數
會有未宣告的問題
Sol:
把該變數加個{}
限制他的scope
3. Invalid application of sizeof to incomplete type with a struct
似乎是OAI的問題
Sol:
自行重新手動定義就可以編譯完成
4. int轉換成enum type
Sol:用static_cast<type>(value)去做轉換
5. unable to find string literal operator ‘operator""PRIx32’ with ‘const char [64]’, ‘long unsigned int’ arguments(2018.01.04更新)
把CMakeList的FLAG改用C++11編譯的時候發生的問題
Sol:
直接去把原本在define裡面的字串貼上去
e.g.:
#define TEID_FMT  "0x%"PRIx32
MSC_LOG_RX_MESSAGE (MSC_S11_MME, MSC_SGW, NULL, 0, "0 DELETE_SESSION_RESPONSE local S11 teid " TEID_FMT " ", resp_p->teid);
代換成
MSC_LOG_RX_MESSAGE (MSC_S11_MME, MSC_SGW, NULL, 0, "0 DELETE_SESSION_RESPONSE local S11 teid " "0x%"PRIx32 " ", resp_p->teid);

6.關於gtp函式的undefined reference(2018.01.10更新)
把libgtpnl相關的header 改回用extern "C"編譯
#include <libgtpnl/gtp.h>
#include <libgtpnl/gtpnl.h>

7.cannot declare member function static func_type func_name(parameter) to have static linkage (2018.01.31 updated)
Sol:
remove static for the definition
e.g.
class Foo
{
    static void Bar();
};

...

static void Foo::Bar()
{
    ...
}
the second "static" should be deleted.

8.invalid use of member function (did you forget the ‘()’ ?)
       obj_hashtable_ts_create (32, NULL, NULL, (void (*) (void **))pgw_lite_cm_free_apn, b);
"pgw_lite_cm_free_apn" is a member function in my class.
Sol:
add "static" declaration to pgw_lite_cm_free_apn in class

沒有留言:

張貼留言