You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue where the field values I get after deserialisation don't match the values I've set.
environments :[C++, gcc 9.3, aarch64, FlatBuffers:23.5.26]
Here is my code, you can see that I set: obstacles_builder.add_confScale(63246); but these two lines of code prints 0 instead:
auto test = message->confScale(); //test
std::cout << test << std::endl;
I think it's the code I bolded that's the problem, because if I remove this code it prints correctly, but I don't understand why
my code:
void GetObstacles(flatbuffers::FlatBufferBuilder& builder, int obstacle_num) {
HeaderBuilder header_builder(builder);
header_builder.add_time_stamp(123456789);
header_builder.add_frame_id(1);
ObstaclesBuilder obstacles_builder(builder);
obstacles_builder.add_header(header_builder.Finish());
obstacles_builder.add_confScale(63246);
**std::vector<flatbuffers::Offset<Obstacle>> obstacles_vector;
for(int i = 0; i < obstacle_num; ++i) {
ObstacleBuilder obstacle_builder(builder);
obstacle_builder.add_id(i);
......
obstacles_vector.push_back(obstacle_builder.Finish());
}
auto obstacles_offset = builder.CreateVector(obstacles_vector);
obstacles_builder.add_obstacle(obstacles_offset);**
auto obstacles = obstacles_builder.Finish();
builder.Finish(obstacles);
size_t size = builder.GetSize();
std::vector<uint8_t> serialized_data(size);
std::memcpy(serialized_data.data(), builder.GetBufferPointer(), size);
const Obstacles* message =
flatbuffers::GetRoot<Obstacles>(serialized_data.data());
auto test = message->confScale(); //test
std::cout << test << std::endl;
}
I'm having an issue where the field values I get after deserialisation don't match the values I've set.
environments :[C++, gcc 9.3, aarch64, FlatBuffers:23.5.26]
Here is my code, you can see that I set:
obstacles_builder.add_confScale(63246)
; but these two lines of code prints 0 instead:I think it's the code I bolded that's the problem, because if I remove this code it prints correctly, but I don't understand why
my code:
my .fbs file:
The text was updated successfully, but these errors were encountered: