1
我在我的SWIG接口文件中有以下結構,因此也是我的sample.h頭文件。我假設這個結構中的sockaddr,ios_boolean和unsigned char定義是我得到下面生成的類的原因。如果我知道在Java端的ios_boolean和unsigned char映射的類型有沒有辦法使用%apply去掉生成的指針類?我試過%apply int {ios_boolean};但後來我得到了一個SWIGTYPE_p_boolean.java。有任何想法嗎?使用SWIG重命名C結構屬性%apply
%rename (Sample) sample_details_t_;
typedef struct sample_details_t_ {
ios_boolean is_allowed;
unsigned char mac[11];
} sample_t;
generates:
SWIGTYPE_p_unsigned_char.java
SWIGTYPE_p_ios_boolean.java
例外:
[exec] ewapi_wrap.c:982: error: `true' undeclared (first use in this function)
[exec] ewapi_wrap.c:982: error: (Each undeclared identifier is reported only once
[exec] ewapi_wrap.c:982: error: for each function it appears in.)
[exec] ewapi_wrap.c:982: error: `false' undeclared (first use in this function
我剛剛嘗試了ios_boolean的建議,並在SWIG生成期間出現錯誤,它似乎無法將ios_boolean轉換爲bool。我在原始問題中添加了異常,因爲如果我在此處添加它,它會變得很糟糕。有任何想法嗎? – c12
@ c12要#include stdbool.h或定義true和false常量或將庫的bool頭包含在接口頂部的%{%}中。 – Flexo