🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9477

Re: Big, Little and Bi endians

#9477
From: Alan Bellingham
Date: Fri, 09 Jul 2004 10:21
23 lines
1723 bytes
<Donut> wrote:

>    How to check in C++ program if our applciation running on a
>Big/Little/Bi Endian machine?

... probably not actually necessary

>    Is there a generic way of transforming data (which could be in any
>structure) between different endians?

Look up the htons, nstoh, htonl, nltoh, WSAHtonl, ... functions. These
functions convert from whatever the hardware uses natively to a neutral
consistent ordering. If you use the same functions on the different
platforms (well, OK, the WSAHxxx functions are Windows specific), then
it should all work fine, since the different platforms will supply their
own versions which Just Do The Right Thing.

Note that the functions may just return whatever they're fed with if
that's already in network order.

Alan Bellingham
-- 
ACCU Conference 2005 - 20-23 April, Randolph Hotel, Oxford, UK
Technical Details
Message-ID: <u1sse0t3kjlaedjkiifjg3ffjf8anhuhb7@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <40ee62ed$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e4fd0ef684fef580
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Alan Bellingham <alanb@episys.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Big, Little and Bi endians
Date: Fri, 09 Jul 2004 11:21:43 +0100
Reply-To: alanb@episys.com
Message-ID: <u1sse0t3kjlaedjkiifjg3ffjf8anhuhb7@4ax.com>
References: <40ee62ed$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 2.0/32.646
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 193.129.251.130
X-Trace: newsgroups.borland.com 1089368501 193.129.251.130 (9 Jul 2004 03:21:41 -0700)
Lines: 23
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail