> Then allocate memory for xP, assign xP->i, etc. > > QUESTION. Is it always legitimate to reference > xP->i by "*((int *) xP)"? > > NOTE. "i" is the very first item in the structure
yes. it is ok however, i would be careful. using 'int' can be variable depending on the platform you are using. you are better of using known data type sizes (short, long, char). > EXAMPLE. This happens in FrmGetWindowHandle() via > WinGetWindowHandle(). it'll work in general since the rom code is compiled against a specific CPU, so, these sizes are known. it wont work however if the structures are represented in ARM, and, you are working with 68k code (int = 32bit vs int = 16bit). thats why internal access to structs isn't really the way to go on OS5 > I would like to know if this legitimate according to the > specification of C and if it is hardware independent. My > guess is that it is OK but I would like to be reassured and > I would even appreciate pointers [no pun intended] for it. pointers are fun. bottom line is that it is just a chunk of memory. using structs is only there to help the compiler and you understand what you want to do :) think about the assembly.. xP->i probrably ends up as (in 68k asm) move a0, (address of xP) move.w d0, (a0) which, effectively is like casting xP into a (int *) array --- Aaron Ardiri [EMAIL PROTECTED] CEO - CTO +46 70 656 1143 Mobile Wizardry http://www.mobilewizardry.com/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
