Structures on the Raspberry Pi (Debian linux)

Václav Zeman vhaisman@gmail.com
Tue Jul 3 06:32:00 GMT 2012


On 07/03/2012 12:23 AM, Ray Newman wrote:
> On 02/07/2012, at 5:23 PM, Václav Zeman wrote:
>
>> On 2 July 2012 08:45, Ray Newman wrote:
>>> Hi,
>>>
>>> I have an implementation of the MUMPS language that has been in use for approx 12 years on the x86 under FreeBSD, linux and OSX.
>>>
>>> In the code there is the following structure definition which describes an on disk structure and hence can't really be changed.
>>>
>>> typedef struct DB_BLOCK                                 // database block layout
>>> { u_char type;                                          // block type
>>>   u_char flags;                                         // flags
>>>   u_short spare;                                        // future
>>>   u_int right_ptr;                                      // right pointer
>>>   u_short last_idx;                                     // last used index off
>>>   u_short last_free;                                    // last free lw in block
>>>   chr_q global;                                         // global name
>>> } DB_Block;                                             // end block header
>>>
>>> This structure works OK on the x86 but on the Raspberry Pi, the global element is extracted from the data commencing at global+4 for 8 bytes.
>>>
>>> Is there some way to force gcc to have global at +12 and not +16 in the structure?
>>>
>>> I tried compiling with the switch -fpack-struct; but this broke the whole thing.
>> You can apply __attribute__((packed)) on just the structure instead.
>> See <http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Variable-Attributes.html#index-g_t_0040code_007bpacked_007d-attribute-2667>.
>>
>> -- 
>> VZ
> Thank you; fixed that problem. One other question, if I may.  Looking for a list of keywords that specify current O/S and hardware such as __APPLE__, __FreeBSD__ - specifically I'm currently looking for something that tells me I am on an ARM.
Run this from your shell: echo | arm-linux-gnueabi-gcc -dD -E - | sort

It will print you all the macros defined by GCC for your ARM compiler.
For me it shows __arm__, __ARMEL__ etc.

-- 
VZ



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20120703/bb24c0d8/attachment-0001.sig>


More information about the Gcc-help mailing list