Enabling Mavlink MAVLINK_USE_MESSAGE_INFO

Hello.

Under C++ - anybody has an experience in enabling helpers with MAVLINK_USE_MESSAGE_INFO directive?
If enabled with -DMAVLINK_USE_MESSAGE_INFO or for example add_compile_definitions(MAVLINK_USE_MESSAGE_INFO) in CMake it fails with compile errors.

Thank you for any clues and responses.
Bartek

1 Like

I suppose no one had a need to enable this.
I’ve found a temporary solution because it needs to be fixed in mavlink generator.

Background: in common.h there’s a macro that creates an array of message infos MAVLINK_MESSAGE_INFO. It gathers all infos from particular messages. Every message define a structure MAVLINK_MESSAGE_INFO_XXX where XXX is a message name, for example MAVLINK_MESSAGE_INFO_HEARTBEAT. But in the structure there’s a use of offsetof macro that is defined (at my system) in stddef.h. This file must be included before.

So basic solution is to add at the top of mavlink_get_info.h

#include <stddef.h>

Maybe there’s better place to do it but for me it’s sufficient for now as I burned an hour to investigate this.

Hope this helps more people.
Bartek

Thanks - it surprises me no one else is interested in this…seems this is pretty much the only way to print the name of a mavlink message without defining your own message number to string mapping. Maybe most people arent’ doing low level stuff with mavlink messages directly. This saved me a lot of time though so thanks.

1 Like