Skip to main content
GameDev.net gamedev.net
🔒 Locked

weird endian errors when compiling on linux

Started by BleedingBlue Oct 13, 2005 at 6:50 PM 1 replies 700+ views
Original Post
BleedingBlue
BleedingBlue
This is the header that causes the error.

#ifndef rbEndian
#define rbEndian
/*
LITTLE_ENDIAN		<--- if compiling for a little endian machine
BIG_ENDIAN			<--- if compiling for a big endian machine
rbMustDefineEndian	<--- if you NEED LITTLE_ENDIAN or BIG_ENDIAN defined

want_rbEndianErrorCheck

Note: Try useing RUxx when possible.
*/

#if ((defined __cplusplus) || (defined _MSC_VER))
	#define want_rbEndianErrorCheck
#endif

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#if		defined(__i386__)		|| 		defined(__i386)			|| 		defined(__ia64__)		|| 		defined(__x86_64__)		|| 		defined(__LITTLE_ENDIAN__)

			#define LITTLE_ENDIAN
#endif

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#if		defined(__POWERPC__)	|| 		defined(__BIG_ENDIAN__)

			#define BIG_ENDIAN
#endif


/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#if (defined LITTLE_ENDIAN) && (defined BIG_ENDIAN)

	#error Both little and big endian are defined

#endif






Ok well the thing is, is that when compiling on Fedora Core 4, it gives me the error "Both little and big endian are defined", I check everything and as far as I know nothing else is defining BIG_ENDIAN not even this header. Could it have something to do with the preprocessor leaving BIG_ENDIAN in an undefined state?
DadleFish
DadleFish
I'd just take all the parts of the conditions and find out what is defined on the system you're running. Something like:

#if defined(__i386__)#pragma message("__i386__")#endif#if defined(__i386)#pragma message("__i386")#endif...


Alternatively I'd put pragma-messages along with the #define-s, so I'd see what really is defined.

Also, in the last if you wrote (defined LITTLE_ENDIAN), and in the others you did "defined(__POWERPC__)" (note the parentheses location). Maybe this is the cause for your problems?
Dubito, Cogito ergo sum.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.