__bigendian__

Aaron Digulla digulla@wi-pc44.fh-konstanz.de
Wed Jan 28 02:17:00 GMT 1998


Several people have proposed to use to ntoh() macros for my problem but
they don't solve my problem. I should have made a better example like this
one:

#define __be attribute((__bigendian__))

struct Window * __be 
OpenWindow (
	struct __be NewWindow * __be nw
)
{
	struct Window * w;
	// Create a window based on the data in nw
	// The pointer nw is in BE format as is the data *in*
	// nw.
	w = ...;

	// Convert the native pointer to BE
	return w;
}

I could use the ntoh() macros for this, but:

- To be type-safe, I'd have to define a conversion macro for every pointer
type.

- This is something which can be automated. If I'd do it manually, then I
would surely miss some places and the resulting errors will be hard to
track.

- It would be an enourmous amount of work to do this in source code (I
have about 7MB sources as of yet and that's about 50% of what I'll have
when the project is finished). 

- I can add __be to the relevant function headers without problem, because
I have to use macros to create the real function headers, anyway, so I
just have to change one macro.

Therefore I concluded that it would be much simpler to do it in the
compiler than doing it in the source code.

--
Aaron "Optimizer" Digulla          Team AMIGA        AROS Head of Development
Author of XDME, ResTrackLib, CInt.                     < http://www.aros.org/ >
"(to) optimize: Make a program faster by improving the algorithms rather than
by buying a faster machine."





More information about the Gcc mailing list