On Fri, Apr 07, 2000 at 08:37:03AM -0400, Philip Hall wrote:
> I have an application that must retreive records from a file that is
> read into a buffer.
> the records consist of the following structure
> struct {
> short wordtype;
> long engwordoff;
> long phonoff;
> } dictrec;
> i have forced it to be packed by using
> __attribute ((packed))
> this is an array of these structures by the way.
>
> the problem comes when reading the records.
> I can fetch engwordoff correct every other fetch.
> the first time I get all 32 bits.
> the next time I only get the lower 16 bits.
> I assume this is because longs must be on a double word boundary.
> is there a way to force gcc to compile with out the restriction?
Not that I know of.
The only portable (and ANSI compliant) way to read packed records from disk is
to read into an array of char and then unpack as necessary, with knowledge of
long/int/short sizes and endian-ness
> this only happens on the netwinder by the way, not on an intel based
> machine.
Not all the world's a VAX.
Nick
unsubscribe: body of `unsubscribe linux-arm' to [EMAIL PROTECTED]
++ Please use [EMAIL PROTECTED] for ++
++ kernel-related discussions. ++