我用SWIG包装一些C ++代码来生成java代码。我有这个typedef
typedef void (*create_cb_t)(const rib_handle_t rib,
const cdap_rib::con_handle_t &con,
const std::string& fqn,
const std::string& class_,
const cdap_rib::filt_info_t &filt,
const int invoke_id,
const ser_obj_t &obj_req,
ser_obj_t &obj_reply,
cdap_rib::res_info_t& res);
稍后在成员函数中使用
void addCreateCallbackSchema(const cdap_rib::vers_info_t& version,
const std::string& class_,
const std::string& fqn_,
create_cb_t cb);
当SWIG生成类型时,文件名太长,使用时会出错
Unable to open file ../../../java/eu/irati/librina/SWIGTYPE_p_f_q_const__long_long_r_q_const__rina__cdap_rib__connection_handler_r_q_const__std__string_r_q_const__std__string_r_q_const__rina__cdap_rib__filtering_info_q_const__int_r_q_const__rina__ser_obj_r_rina__ser_obj_r_rina__cdap_rib__result_info__void.java: File name too long
如何使用避免此问题的名称替换(我想重命名)typedef?
由于
答案 0 :(得分:0)
此问题的解决方案是在接口文件中创建特定的typedef(尊重命名空间):
namespace rina {
namespace rib{
typedef void (*create_cb_t)(const rib_handle_t rib,
const cdap_rib::con_handle_t &con,
const std::string& fqn,
const std::string& class_,
const cdap_rib::filt_info_t &filt,
const int invoke_id,
const ser_obj_t &obj_req,
ser_obj_t &obj_reply,
cdap_rib::res_info_t& res);
}}
然后忽略.h
中的typedef#ifndef SWIG
typedef void (*create_cb_t)(const rib_handle_t rib,
const cdap_rib::con_handle_t &con,
const std::string& fqn,
const std::string& class_,
const cdap_rib::filt_info_t &filt,
const int invoke_id,
const ser_obj_t &obj_req,
ser_obj_t &obj_reply,
cdap_rib::res_info_t& res);
#endif