[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Paparazzi-devel] I need an expert in C

From: Cédric Marzer
Subject: [Paparazzi-devel] I need an expert in C
Date: Fri, 4 Sep 2009 08:47:41 +0200



My OSD makes good progress but I am stuck with some C trick.

The messages are stored in an array each char, short or long following each other.

I want to map this message into different structures (for the gps message, the batterie message, etc.).


The crude way to do that (it works), is the following :



But that means that I will write a dozen of this for each message…


The (not so smart) way is to do that :




but there is a trap…

When you make a structure, the compiler makes sure that the short and long are aligned in the memory

and add gaps after let's say a char to make sure that the next long is well aligned in the memory.

That means that the data in my array and in the structure are not aligned. The process to put the gaps is called "padding".


Some compiler and processor allow one to disable "padding". I doubt that this is the case with arm.


So does anyone of you have a smart idea for a clean work around ? Otherwise I will just go the crude way…





reply via email to

[Prev in Thread] Current Thread [Next in Thread]