From: "John S. Fine" Newsgroups: comp.os.msdos.djgpp Subject: Re: Casting pointers Date: Wed, 19 Jan 2000 17:34:07 -0500 Lines: 35 Message-ID: <38863BDF.44@erols.com> References: <865adi$tbm$1 AT bird DOT wu-wien DOT ac DOT at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: GVR3v0yllKsmFrW/jKSfs2HJi1mHwG3HXSSCc2jphF4= X-Complaints-To: abuse AT rcn DOT com NNTP-Posting-Date: 19 Jan 2000 22:37:14 GMT X-Mailer: Mozilla 3.01 (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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/