On Sat, 2004-07-31 at 00:03, Timo Sirainen wrote:
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.
No, for one can always:
typedef char _structure_ext[1];
sizeof(struct foo)-sizeof(_structure_ext)
-- Geo Carncross geocar@internetconnection.net Internet Connection Reliable Web Hosting http://www.internetconnection.net/