HI Iam having problem when pointer to the location is not on a 4 byte boundary (divisible by 4). when i call the function and pass arguments, i see that inside the called function, it points to an aligned memory location which is probably pointing to second or third byte.(I was expecting it to point to the first byte).
Since i have to type pointer to structure and pass it on as argument to a function, using __packed is also not useful.
Is there a work around?
-vivek
it would be interesting to see a subset of the code that causes the problem. how come the data is unaligned? are you parsing an image? you can to work with pointer to an 'unsigned char', if you can modify the prototype of your function.
The right combination of packed should tell the compiler what it needs to know. Try defining both the pointer to the structure and the structure as packed. It is really the function that is being called that needs to know that the item may be unaligned so the pointer passed in needs to be packed.
The pointer don't need to be packed, but of the type "pointer to packed object". This is a bit similar to a const pointer and a pointer to const data.
Yes, Per is correct. Packing the structure is enough to allow any pointer to the structure to also be unaligned, not just the items within the structure.
View all questions in Keil forum