Csound Csound-dev Csound-tekno Search About

[Cs-dev] automatic endian configuration

Date2006-10-29 01:21
FromAnthony Kozar
Subject[Cs-dev] automatic endian configuration
I've noticed that SConstruct (and the sfont library, I think) makes
assumptions about endianness that are not always true (OS X = big endian,
and Linux = little endian).  And yet people are compiling on Intel Macs and
such.  For example, there is this code in SConstruct:

if getPlatform() == 'win32':
    stkEnvironment.Append(CCFLAGS = '-D__OS_WINDOWS__ -D__LITTLE_ENDIAN__')
elif getPlatform() == 'linux':
    # N.B. these assumptions about endianness may be incorrect
    stkEnvironment.Append(CCFLAGS = '-D__OS_LINUX__ -D__LITTLE_ENDIAN__')
elif getPlatform() == 'darwin':
    stkEnvironment.Append(CCFLAGS = '-D__OS_MACOSX__ -D__BIG_ENDIAN__')
 

Wouldn't it be fairly easy to write a test program for SCons to build and
run that would determine the endianness of the platform?  Something such as
this I think would work:


/* This code modified from pvfileio.c: */
/* thanks to the SNDAN programmers for this! */
/* return 1 for big-endian machine, 0 for little-endian machine */

int main()
{
    const int one = 1;
    return (!*((char*) &one));
}


Anthony Kozar
anthonykozar AT sbcglobal DOT net



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net