Re: Structures on the Raspberry Pi (Debian linux)

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

 



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



Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux