31 Jul
2004
31 Jul
'04
7:03 a.m.
On 28.7.2004, at 01:51, Geo Carncross wrote:
On Tue, 2004-07-27 at 17:36, Timo Sirainen wrote:
You use "char var[0]" in end of some structures. I've tried to avoid them so far everywhere since C89 doesn't support it. But I guess it's common enough feature that it could be allowed the way C99 supports it, var[].
var[1] is safe and then malloc-1. Still C89-ok.
BTW. This works only as long as you don't care if sizeof() returns more data than the structure actually uses. struct foo { int size; char data[1]; }; sizeof(foo) == 8 with most compilers nowadays because of alignmentation issues.