In the case of bit field, the information within the byte is processed in opposite order by the compiler on little and big endian systems. They are not flipped while writing/reading from memory. It can be confirmed by seeing the assembly code of a small program. Manoj -----Original Message----- From: kernelnewbies-bounce@nl.linux.org [mailto:kernelnewbies-bounce@nl.linux.org] On Behalf Of Ed L Cashin Sent: Sunday, May 02, 2004 10:53 AM To: kernelnewbies@nl.linux.org Subject: Re: Big and little indian valid in a byte?? Jan Hudec <bulb@ucw.cz> writes: > On Fri, Apr 30, 2004 at 14:37:59 +0530, syedk wrote: >> Hi All, >> >> This is the structure declaration of IP Header. Can you tell me >> how >> little endian and big endian come into picture in the case of a >> byte. U can find this declaration in >> /usr/src/linux-2.4.18-14/include/linux/ip.h. >> >> struct iphdr { >> #if defined(__LITTLE_ENDIAN_BITFIELD) >> __u8 ihl:4, >> version:4; >> #elif defined (__BIG_ENDIAN_BITFIELD) >> __u8 version:4, >> ihl:4; > > You sure know, what the :4 modifier means. It seems like although it is just a feature of C, many people don't know about bitfields. It's part of the syntax for a bitfield -- four bits in this case: a "nibble". > So you should know, what's > the difference between these two declaratinons. And thus know, what in > the compiler is affected by endianity. OP, note the order or the nibbles. -- --Ed L Cashin | PGP public key: ecashin@uga.edu | http://noserose.net/e/pgp/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/