Thread: autoconf endian test

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    9
    I developed a library that performs various formatting for RIFF chunks, and it is absolutely dependent on the endianness of the system. I am porting it to a wider range of systems, but the issue remains for testing the endianness.

    I am using autoconf for the configuring aspect of the project.

    Is there a way in Configure.in to test for endianness?

    got it
    AC_C_BIGENDIAN
    Last edited by Scramble; 03-11-2011 at 07:01 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Why are you writing code that is dependent on endian?

    That would only make sense if you're trying to read blocks of data directly from the file, and assuming that you can just drop it on top of say an int and it will work.

    If you treat the file as a stream of bytes, and assemble byte-by-byte the actual data elements, say
    unsigned short foo = buff[0] + (unsigned short)buff[1] << 8;
    then the whole endian problem goes away.

    Besides, "big" and "little" are not the only choices.
    Endianness - Wikipedia, the free encyclopedia

    By the time you've written all the hacks for all the possible combinations, you may as well have done the job the simple (if a little tedious at the outset) way from the start.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Integer Emulation
    By Elysia in forum C++ Programming
    Replies: 31
    Last Post: 03-18-2008, 01:03 PM
  2. undefined reference
    By 3saul in forum Linux Programming
    Replies: 12
    Last Post: 08-23-2006, 05:28 PM
  3. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  4. MSVC Template Constructor/Assignment Errors
    By LuckY in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:57 PM
  5. Question About Linker Errors In Dev-C++
    By ShadowMetis in forum C++ Programming
    Replies: 9
    Last Post: 08-18-2004, 08:42 PM