what about alignment problems?

Kevin Martin kpmartin at watmath.UUCP
Thu Jul 12 21:57:13 AEST 1984


After all, not everyone has ints, longs, and pointers all of the same size
and alignment...

There is currently no way in C to get the alignment required by a type.
This makes writing a special-purpose storage allocator difficult. It also
means that it is difficult to write a varargs function cleanly (since
stepping though the args required aligning the pointer to the next boundary
appropriate for the next type).

Would it not be useful to have an 'alignof' operator, with the same usage
as 'sizeof', but which returns the byte alignment required by the given
type or expression?

About the only reason against this is the 'yet *another* keyword' problem.



More information about the Comp.lang.c mailing list