endian dilemma

Jerry Feldman gaf at blu.org
Fri Sep 6 11:20:54 EDT 2002


That stuff all works. #pragma pack is generally used by most compilers 
(with different syntax).   There are all sorts of ways to get around this 
things. The communications industry has defined many ways to solve the 
problem of transferring data between different systems. (I once worked on a 
POS device based on a DEC PDP-8 which used 12 bit words). We would send a 
binary dump of the data page to an EBCDIC mainframe that had to convert the 
data to something a COBOL program could make sense with. (The comm code was 
Burrough's COBOL sprinkled with "ENTER SYMBOLIC" which was the COBOL 
equivalent of ASM()). 

One real problem is when systems need to share the same physycal disks. 
Gets real messy. 
On 6 Sep 2002 at 10:56, Kevin D. Clark wrote:
> Sometimes, if the stars are in alignment (no pun intended!), you can
> do things like:
> 
> 
> struct Foo {
>   uint32_t field1;
>   uint64_t field2;
>   uint32_t field3;
> };
> 
> sprinkle some compiler #pragmas around this, as appropiate.  And then
> you can be reasonably certain that the compiler did what you wanted if
> you put <something like> this in your code:
> 
> assert(sizeof(struct Foo) == sizeof(Foo::field1) + sizeof(Foo::field2) + sizeof(Foo::field3));
> 
> Of course, the day that this assert() call throws an exception is the
> day that you're in for some work.  But at least it won't die
> silently...
> 
> Regards,
> 
> --kevin
> -- 
> Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
> cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
> alumni.unh.edu!kdc
> 
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://www.blu.org/mailman/listinfo/discuss


-- 
Jerry Feldman <gaf at blu.org>
Associate Director
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9




More information about the Discuss mailing list