This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Endian Macros - are there any defaults


Hi all,

I know that gcc defines some preprocessor macros that let the
preprocessor generate different code for different architectures (I'm
using some of them) but I can't seem to find any that tell me about
either data format (big or little endian) or invocation options. Does
anyone know of anything I can use.

I have just had to add yet another target system to the list that my
code needs to support, unfortunately this one is the same CPU core as we
are already using (ARM7) but is configured as Big Endian instead of
Little Endian.

Getting the tools to generate the correct code (and even to use the
correct libraries) is working, and wasn't too much of a problem. The
place I am running into headaches is in the application code, especially
communications and mass storage, where data format is an issue.

Currently there is a set of header files that check for the target CPU
(i.e. look for the preprocessor macros __sh__ and __arm__ and set up any
endian related macros. I've had to add an additional macro to the
compiler invocation when using the -mbig-endian option I also add
-DBIGENDIAN and then add this to the header file tests.

However, I've already run into a problem where someone used a toolchain
that was configured for big-endian, so he didn't need the option and
didn't define the macro. Result was several hours of confusion.

It would be ideal if there was a standard macro that told me the
endianness (I can see that there would probably be macros for integer
and floating point formats, etc.) so that I didn't have to rely on my
macro being defined but I can't see anything like this in the
documentation.

Does anyone have any suggestions.


Thanks
Stan Katz


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]