[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: Portable Code (am I dreaming? :))
From: Clarence Dang <CTRL_CD () bigpond ! com>
Date: 2002-01-15 0:25:30
[Download RAW message or body]
On Sun, 13 Jan 2002 21:54, shaheed wrote:
> Hi Clarence,
>
> > Do I have to care about making filter code portable?
>
> I think you should. The MS Word filter started off (consciously, see below)
> being little-endian and unaligned access dependent, and I soon found that
> Ihad both Sparc and Alpha users. The MS Word filter has hooks for both
> these platforms (see macro crap in mswordgenerated.h), but amazingly
> enough, there are platforms for which the appropriate compiler pragmas do
> not seem to exist (Irix and possibly HPUX).
>
Just wondering but does #pragma pack(1) exist and work for all platforms?
I don't think it's ISO C++ but it's GNU so should work everywhere?
I notice that you have:
#ifndef __GNUC__
#define __attribute__(a)
#pragma pack(1)
#endif
So what do I, if I they're not using GNU (is anyone not?)?
Also, is this portable:?
FILE *filepointer;
struct
{
int a;
int b;
} mystruct;
fread (&mystruct, sizeof (int), 2, filepointer);
if (mystruct.a == some_magic_number)
do_something ();
Will bit order affect the "mystruct.a == some_magic_number" test?
> I finally started work to fix this (it is "easy" in my case because I
> generated the code involved), but have not yet finished.
>
How do I test my code, without having the target system?
I only have ix86 systems.
> > With non-portable expressions like these, which make assumptions on data
> > type sizes and byte ordering and bit ordering...
>
> The first step is to use Q_{U,}INT{8,16,32} as I believe you can trust
> these to be set correctly on any platform. Then, QDataStream in little
> endian mode may be your friend. If only I had known about these when I
> started...
>
Thanks for the information.
Thanks!
Clarence
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic