It sounds like a issue with the padding the compiler inserts to align fields
with 2- and 4-byte boundaries. The simplest way to avoid problems is to put
4-byte fields first, followed by 2-byte fields, followed by 1-byte and array of
byte fields. (Though 68K processors only require 2-byte alignment for 4-byte
quantities, the compiler may be set for 4-bytes alignment.)
I'm not sure how a struct within a struct is treated -- you'd have to get
pretty deep into the GCC docs to be sure what's documented. At a guess, it
requires the alignment of its most-restrictive member (which in your case would
be 1-byte). But putting the struct at the end (or beginning) of the
containing struct sounds sensible to me.
In any case, after changing the order of the struct, be sure every .c file
which references it is recompiled. (I just do a clean and build.) And, of
course, be sure all .c files are compiled with the same compiler flags.
----- Original Message -----
From: Tam Hanna <[EMAIL PROTECTED]>
Date: Wednesday, May 21, 2008 5:22 pm
Subject: Weird Pref problem
To: Palm Developer Forum <[email protected]>
> Dear Friends,
> I have a really really weird bug to report in relation to prefs
> can anyone
> explain this to me?
>
> I have the following structure and save and load it as
> prefs(using PODS 1.2
> as a compiler):
> 1.
> 2. dies
> 3.
> 4. typedef struct{
> 5. UInt16 appNetRefNum;
> 6. NetSocketRef socketRef;
> 7. NetIPAddr addr;
> 8. UInt16 port;
> 9. char server[51]; // 50+1 Not sure on
> this one
> 10. char channel[31]; // 30+1
> 11. char nick[17]; // 16+1
> 12. char pass[17]; // 16+1
> 13. OptionsType display;
> 14.
> 15. struct
> 16. {
> 17. Boolean enabled;
> 18. Boolean logPvt;
> 19. Boolean filePerChannel;
> 20. char volname[40];
> 21. char parent[256];
> 22. }logging;
> 23.
> 24. //Copyright prefs
> 25. UInt32 firstusesecs;
> 26. char regcode[15];
> } myIRCPreferenceType;
>
> The copyright prefs can not be accessed or rather turn out as
> zero when the
> structure is read into memory. However, when I change the
> structure around
> to put the defines at the top, the program suddenly works(below):
> 27. works
> 28.
> 29. typedef struct{
> 30. //Copyright prefs
> 31. UInt32 firstusesecs;
> 32. char regcode[15];
> 33. UInt16 appNetRefNum;
> 34. NetSocketRef socketRef;
> 35. NetIPAddr addr;
> 36. UInt16 port;
> 37. char server[51]; // 50+1 Not sure on
> this one
> 38. char channel[31]; // 30+1
> 39. char nick[17]; // 16+1
> 40. char pass[17]; // 16+1
> 41. OptionsType display;
> 42.
> 43. struct
> 44. {
> 45. Boolean enabled;
> 46. Boolean logPvt;
> 47. Boolean filePerChannel;
> 48. char volname[40];
> 49. char parent[256];
> 50. }logging;
> 51.
> 52.
> 53. } myIRCPreferenceType;
> 54.
>
>
> Anybody any ideas on what is going on here?
>
> Best regards from Vienna
> Tam Hanna
>
>
> --
> For information on using the ACCESS Developer Forums, or to
> unsubscribe, please see http://www.access-
> company.com/developers/forums/
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/begin:vcard
n:Reeder;Doug
fn:P. Douglas Reeder
tel;work:614-292-1059
org:Ohio State University;School of Music/College of the Arts
adr:;;121 Weigel Hall
1866 College Rd.;Columbus;OH;43210;USA
email;internet:[EMAIL PROTECTED]
title:Systems Specialist
version:2.1
end:vcard