public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Structure layout in big/little endian modes
@ 2011-11-23 21:31 Владимир Андреев
  2011-11-23 22:10 ` Ian Lance Taylor
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Владимир Андреев @ 2011-11-23 21:31 UTC (permalink / raw)
  To: gcc-help

Hello all!

I have some lack of understanding how to write endianness independent
definition of structure, which contains bit fields.

For example, field, containing endpoint address in endpoint descriptor
of USB device, can be defined as follow:

struct EndpointAddress
{
    UnsignedByte EndpointNumber: 4;
    UnsignedByte: 3;
    UnsignedByte TransferDirection: 1;
};

All USB descriptors have little endian byte order (and filling
starting from least significant bit). If I would run some code which
uses such definition on big endian CPU, I will get incorrect result.

Can I tell GCC to use for layout big/little endian mode without manual
changing structure layout for target CPU?

-- 
With best regards, Vladimir

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <CAJXPUY+H_iS7=iRdxiF+JS0iycJV7d12XK3+1k=NU69=D0se_A@mail.gmail.com>]

end of thread, other threads:[~2011-11-26 17:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 21:31 Structure layout in big/little endian modes Владимир Андреев
2011-11-23 22:10 ` Ian Lance Taylor
2011-11-24  8:00 ` Paweł Sikora
2011-11-24 12:31 ` David Brown
2011-11-26 17:04   ` Владимир Андреев
2011-11-26 17:23     ` Ian Lance Taylor
2011-11-27  5:20       ` David Brown
2011-11-27 21:25         ` David Brown
2011-11-28 10:23         ` Ian Lance Taylor
2011-11-28 13:30           ` Владимир Андреев
     [not found] <CAJXPUY+H_iS7=iRdxiF+JS0iycJV7d12XK3+1k=NU69=D0se_A@mail.gmail.com>
2011-11-24  8:09 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).