|
From: | Michele Santucci |
Subject: | Re: [Paparazzi-devel] I need an expert in C |
Date: | Fri, 4 Sep 2009 09:31:04 +0200 |
Hallo Cédric,
if I understood your problem the workaround could be a
compiler directive to override the
default compiler memory
aligment policy, of course this directive is strongly bound to the
compiler itself but it usually
sounds like a 'pragma' directive i.e. #pragma option
push -a1,
#pragma pack(1). Anyway look into compiler manual and
you will find this information easily.
From: Cédric Marzer
Sent: Friday, September 04, 2009 8:47 AM
To: address@hidden
Subject: [Paparazzi-devel] I need an expert in C Hello, 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
: gps.utm_north=MAKE32(array[12],array[11],array[10],array[9]; etc. But that means that I will write a dozen of this for each
message
The (not so smart) way is to do that : gpspointer=&array+4 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
Cheers Cédric
_______________________________________________ Paparazzi-devel mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/paparazzi-devel |
[Prev in Thread] | Current Thread | [Next in Thread] |