Hello all,
Previously i was using MDKARM 4.0 and now i've upgraded to the 4.7. I am writing the program for LPC17xx. In the previous version i was using unsigned long long data type for 64 bit data storage. When i want to store the data in buffer i was using following
*(unsigned long long *)buf->dptr = n->ex;
where ex is __packed unsigned long long data type.
I used __packed because of the data alignment boundary.
Now when i am upgraded to 4.7 same instruction gave me unaligned fault, may be because of some changes in compiler. Just out of the hunch i changes above statement to following
*(__packed unsigned long long *)buf->dptr = n->ex;
Now there is now unaligned fault. I just wanted to ask if it is the correct way or it may lead to unexplained behavior in future. If not what could be the correct way to typecast. Please point me in correct direction.
Thanks in advance Ra
You are assuming that __packed can be used like a typecast - is that true?
(One) of my assumptions is that if this declaration:
does not generate a warning or an error is that it must be allowable.
That said, my main point is that if the value being stored from a declared packed location into a non-declared location, regardless of how a pointer is cast, should generate a warning/error as the source and destination addresses do not have the same restriction.
For example, if the source is say at address 0x80000001 and the destination is at 0x80000010 then it should be flagged as potentally an incorrect transfer strictly based on address incompatibility, which is what I assume a compiler should check. It may be checking other things too, but I have no knowledge as to what they would be.
View all questions in Keil forum