modbus_master.cpp: In function ‘void* querySlaveDevices(void*)’: modbus_master.cpp:445:110: error: cannot convert ‘querySlaveDevices(void*)::st_men_data*’ to ‘st_mem_data*’ in assignment tempBuff = (struct st_men_data *)mmap(0,data_len,PROT_READ | PROT_WRITE, MAP_SHARED, fd,0); ^ modbus_master.cpp:445:40: note: class type ‘querySlaveDevices(void*)::st_men_data’ is incomplete tempBuff = (struct st_men_data *)mmap(0,data_len,PROT_READ | PROT_WRITE, MAP_SHARED, fd,0); ^~~~~~~~~~~ modbus_master.cpp:467:86: error: invalid types ‘uint8_t {aka unsigned char}[int]’ for array subscript bool_input_buf[bool_input_index] = tempBuff->stInput[0][j]; ^ modbus_master.cpp:487:112: error: cannot convert ‘querySlaveDevices(void*)::st_men_data*’ to ‘st_mem_data*’ in assignment tempBuff = (struct st_men_data *)mmap(0, data_len,PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); ^ modbus_master.cpp:487:40: note: class type ‘querySlaveDevices(void*)::st_men_data’ is incomplete tempBuff = (struct st_men_data *)mmap(0, data_len,PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); ^~~~~~~~~~~ modbus_master.cpp:491:48: error: invalid types ‘uint8_t {aka unsigned char}[int]’ for array subscript tempBuff->stOutput[0][j] = bool_output_buf[bool_output_index]; 以上报错问题是什么原因导致的
时间: 2024-02-10 09:08:55 浏览: 122
master.zip_Qt:modbus_qt中master
这些错误的原因是在代码中尝试将 `querySlaveDevices(void*)::st_men_data` 类型转换为 `st_mem_data*` 类型,但这两个类型不兼容,因为它们是不同的结构体类型。这可能是由于代码中定义的结构体类型名称不一致所导致的。另外,也可能是在使用 `tempBuff` 指针时出现了问题,导致无法访问正确的内存位置。建议您仔细检查代码,确保所有结构体类型名称一致,并且使用指针时正确地指向了需要访问的内存位置。
阅读全文