[Gambas-devel] Interface of gb.opengl.sge

Tobias Boege tobias at ...692...
Thu Mar 28 16:30:12 CET 2013


On Thu, 28 Mar 2013, Tomek wrote:
> >>Question 1 - How do I check endianess of the CPU from component level?
> >You must read a well known two or four bytes integer value from the file
> >with fread, and see if you get it swapped or not.
> >
> >If you get it swapped, then you know that all binary values must be swapped.
> >
> >You can use the magic identifier at the beginning of the file, but
> >beware that you must check it byte by byte before reading it as a binary
> >data.
> >
> >Otherwise you may take some files starting with the magic number
> >inverted as MD2 model files!
> As I absolutely have no means to test Big-Endianness, I think I'll
> just put GB.Error("Big Endian not supported yet."), if reading
> header gives reversed value.

I think the better strategy would be to *try* to implement endianess-neutral
code and let big endian users complain if it doesn't work correctly. The
obvious rationale is that you make progress with this method.

I don't know anything about the files you're opening but endian problems can
easily be solved by means of <endian.h>. Is there any reason not to use it?

Regards,
Tobi





More information about the Devel mailing list