虽然这个问题以前曾在社会上提出过,但其他的个案与我的不同,而他们的解决办法亦不能适用于我的个案。
因此,我有一个非常大的标题"rrc_nbiot.h“文件,其结构如下:
#include "rrc.h"
namespace asn1 {
namespace rrc {
...
// SystemInformationBlockType2-NB-r13 ::= SEQUENCE
struct sib_type2_nb_r13_s {
struct freq_info_r13_s_ {
bool ul_carrier_freq_r13_present = false;
carrier_freq_nb_r13_s ul_carrier_freq_r13;
uint8_t add_spec_emission_r13 = 1;
};
using multi_band_info_list_r13_l_ = bounded_array<uint8_t, 8>;
struct freq_info_v1530_s_ {
tdd_ul_dl_align_offset_nb_r15_e tdd_ul_dl_align_offset_r15;
};
// member variables
bool ext = false;
bool multi_band_info_list_r13_present = false;
bool late_non_crit_ext_present = false;
rr_cfg_common_sib_nb_r13_s rr_cfg_common_r13;
ue_timers_and_consts_nb_r13_s ue_timers_and_consts_r13;
freq_info_r13_s_ freq_info_r13;
time_align_timer_e time_align_timer_common_r13;
multi_band_info_list_r13_l_ multi_band_info_list_r13;
dyn_octstring late_non_crit_ext;
// ...
// group 0
bool cp_reest_r14_present = false;
// group 1
bool serving_cell_meas_info_r14_present = false;
bool cqi_report_r14_present = false;
// group 2
bool enhanced_phr_r15_present = false;
bool cp_edt_r15_present = false;
bool up_edt_r15_present = false;
copy_ptr<freq_info_v1530_s_> freq_info_v1530;
// sequence methods
SRSASN_CODE pack(bit_ref& bref) const;
SRSASN_CODE unpack(cbit_ref& bref);
void to_json(json_writer& j) const;
};
...
} // namespace rrc
} // namespace asn1上面的struct中声明的成员函数"pack“是在另一个文件中定义的。"rrc_nbiot.cc“
// SystemInformationBlockType2-NB-r13 ::= SEQUENCE
SRSASN_CODE sib_type2_nb_r13_s::pack(bit_ref& bref) const
{
/* some code */
return SRSASN_SUCCESS;
}在我的主文件"main.cpp“中,我实例化了这个结构,并尝试以这样的方式调用成员函数:
#include "srsran/asn1/rrc_nbiot.h"
struct asn1::rrc::sib_type2_nb_r13_s sib2;
struct asn1::rrc::sib_type2_nb_r13_s *sib2_ref = &sib2;
int main(int argc, char** argv)
{
uint8_t buf[1024];
uint32_t nof_bytes = 2;
asn1::bit_ref bref;
sib2_ref->pack(&bref);
...当我编译时,我得到了错误:
错误:没有调用‘asn1::rrc::sib_type2_nb_r13_s::pack(asn1::bit_ref*)’的匹配函数
sib2 2_ref->pack(&bref);“
尽管正如您在头文件中看到的那样,"pack“显然是在"sib_type2_nb_r13_s”下声明的。结构的其他成员不是我可以访问和修改的函数,没有任何问题,但是调用像"pack“这样的成员函数会给我带来这个错误。
任何帮助都是非常感谢的。
发布于 2022-01-05 13:14:31
感谢评论中的@molbdnilo,我修正了错误。就像他说的那样。
当我调用成员函数时,我不应该将参数作为指针传递给我。论点应该是这样的:
sib2_ref->pack(bref);https://stackoverflow.com/questions/70592980
复制相似问题