Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory alignment in Keil ARM Compiler (thumb instruction set) #183

Open
andersonrs66 opened this issue Aug 25, 2023 · 0 comments
Open

Memory alignment in Keil ARM Compiler (thumb instruction set) #183

andersonrs66 opened this issue Aug 25, 2023 · 0 comments

Comments

@andersonrs66
Copy link

I am using MQTT-C in a bare-metal project on Keil MDK 5 and I encountered an issue with memory alignment.
I noticed that the returned structure members from mqtt_mq_get were shifted by 1 or more bits. Then leading to messages with the wrong payload size and some other random errors.

The problem stopped when I added the packed attribute to the struct mqtt_queued_message.

Before:

struct mqtt_queued_message {

After:

struct __attribute__((packed)) mqtt_queued_message {

I don't know if it's the best solution but it fixed my problem, so I thought I should report it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant