I figured out what was causing the database shifting problem that happened
when I migrated my application from GCC to CW.
If you use the classic C nomenclature from Kernighan and Ritchie for
defining bit fields, it looks something like this:
struct {
unsigned bitfield1 : 1;
unsigned bitfield2 : 1;
unsigned bitfield3 : 1;
} flags;
I wrote my original GCC program using this structure, and it always worked
fine.
typedef struct
{
unsigned selected : 1;
unsigned itemtype : 1;
unsigned hidden : 1;
unsigned sublistID : 5;
Byte bListID;
UInt uiNumMaster;
} PackedList;
When I compiled the above code with CW and ran it, it looked like my data
was being shifted by one or two bytes and the shift got progressively worse
the further along in the data I went.
I fixed the problem in CW by changing the type from 'unsigned' to 'UChar' so
the structure looked like this.
typedef struct
{
UChar selected : 1;
UChar itemtype : 1;
UChar hidden : 1;
UChar sublistID : 5;
Byte bListID;
UInt uiNumMaster;
} PackedList;
Now everything lines up!
So what is happening? GCC compiled my 'unsigned' bit fields into one byte;
CW used two bytes. By explicitly telling CW to use one byte by using UChar,
it behaves like GCC.
Mitch Fawcett
Tapn'see Software
Home of SuperList2
http://www.tapnsee.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/