Re: Info of gcc constants (defines) for native/host endianess

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

 



 <suresh.t <at> philips.com> writes:

> 
> hi,
> 
> I would like to use the host endianess (LITTLE or BIG endian) information 
> in my code. Can someone tell me what gcc flags are available for this 
> purpose.
> I believe that gcc built for for different platforms  (linux/solaris/hp 
> etc) will interally have flags that can give this info. 
> Can someone give me the specifics please.

Not quite what you ask for, but I found this code snippet lying about... can't 
vouch for its correctness (let alone portability - looks like 32-bit only):


  // detect computer architecture
  union {double f; uint32 i[2];} etest;
  etest.f = 1.0;
  if      (etest.i[1] == 0x3FF00000) Architecture = LITTLEENDIAN;
  else if (etest.i[0] == 0x3FF00000) Architecture = BIGENDIAN;
  else                               Architecture = NONIEEE;

Regards,
Lionel



[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