mathog <> writes:
> Keith Thompson wrote:
>> mathog <> writes:
>>
>> How would your proposal handle this on hardware with strict alignment
>> requirements?
>>
>> #include <stdio.h>
>>
>> void func(int *ptr) {
>> printf("*ptr = %d\n", *ptr);
>> }
>>
>> int main(void) {
>> memstruct foo {
>> char c;
>> int i;
>> };
>> memstruct foo obj = {'x', 42};
>> func(&obj.i);
>> return 0;
>> }
>>
>> The problem: the `i` member of `memstruct foo` may be misaligned, but
>> `func()` has no way of knowing that.
>
> memstruct != struct
Perhaps the simplest way to describe it would be that members of a
memstruct act like bit fields. You can access them directly, but you
can't take their addresses.
[snip]
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"