Mail Archives: djgpp/2000/01/19/17:59:07
Wormy wrote:
> printf ("%d\n",textstring[0]);
>
> But is there a way to get a long representation of the first 4 Bytes - with
> a pointer cast or so...
. . .
> longvalue = textstring[0]<<24 || textstring[1]<<16 || textstring[2]<<8 ||
> textstring[3]
Let me clarify your question.
What you want is a cast to give you a long with the
bytes assembled the way they would have been on an MSB
first machine. You want it to work that way in DJGPP
which runs on an LSB first machine.
I strongly doubt there is a way to do that with one
cast. There may be a way to cast as an ordinay long
(*(long *)textstring) and then reverse the order of
the bytes by some method faster than the shifts you
showed above.
There ought to be an (inline) function defined in
some .h file to reverse the bytes in a long, so you
can use longs from MSB sources (data files or network
protocols) in an LSB program. The compiler ought to
be able to generate the faster version of that inline
code that needs a ???+ (I forget which) CPU if your
command line switches promise that CPU. All that is
"ought to be". I haven't dug through any documentation
to see if it really is there.
--
http://www.erols.com/johnfine/
http://www.geocities.com/SiliconValley/Peaks/8600/
- Raw text -