Afficher un message
Vieux 20/10/2007, 13h31   #1
Charlie Gordon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: About little big endian in C

"Kenneth Brody" <kenbrody@spamcop.net> a écrit dans le message de news:
470BBAEF.94FC0D04@spamcop.net...
> user923005 wrote:
> [...]
>> 20.9: How can I determine whether a machine's byte order is big-
>> endian
>> or little-endian?
>>
>> A: One way is to use a pointer:
>>
>> int x = 1;
>> if(*(char *)&x == 1)
>> printf("little-endian\n");
>> else printf("big-endian\n");
>>
>> It's also possible to use a union.
>>
>> See also question 10.16.
>>
>> References: H&S Sec. 6.1.2 pp. 163-4.

>
> I supposed that, techincally, the answer is incomplete at best.
> What happens on sizeof(char)==sizeof(int) systems? (And, on such
> systems, is "endianness" even relevent?)
>
> Then there are systems with some horrible mixed-endianned storage,
> where the 32-bit value 0x11223344 would be stored: 22 11 44 33.
> (Or is it 33 44 11 22?)


None still in production. You are refering to some PDP systems from more
than 30 years ago.

--
Chqrlie.


  Réponse avec citation
 
Page generated in 0,05808 seconds with 9 queries