Duane Ellis wrote: > micheal> [c requires aligned pointers] > > No, The C standard states it is implementation defined, i don't have a > copy handy to quote chapter & verse. I can't find it either. What I found was (in C99):
6.5.3.4: The implementation of the alloc function should ensure that its return value is aligned suitably for conversion to a pointer to double. 6.7.2.1: Each non-bit-field member of a structure or union object is aligned in an implementationdefined manner *appropriate to its type*. 7.20.3: The order and contiguity of storage allocated by successive calls to the calloc, malloc, and realloc functions is unspecified. The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object and then used to access such an object or an array of such objects in the space allocated (until the space is explicitly deallocated). Regarding structures: since it is allowed to take a pointer to a member in a struct, and use that like a normal pointer to that type, the element in the struct needs to be aligned, and thus the whole struct needs to be suitably aligned. Now even if the requirement to have pointers aligned or not is implementation-defined, there *are* plattforms where pointers need to be aligned, and that means that portable code needs to cope with that. cu Michael _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development