Subject: Re: c99 in KNF?
To: Chapman Flack <nblists@anastigmatix.net>
From: Matthew Mondor <mm_lists@pulsar-zone.net>
List: tech-kern
Date: 01/13/2006 13:36:28
On Fri, 13 Jan 2006 13:13:32 -0500
Chapman Flack <nblists@anastigmatix.net> wrote:
> I looked in the gcc 2.95.3 manual and it already supported initializers
> with designators, e.g. { .d_open = fooopen, .d_close = fooclose } which
> is being used to good advantage in FreeBSD to reduce reliance on exact
> struct layouts. So that should be usable even on the current vax port.
>
> The manual didn't say, though, whether unmentioned fields get explicitly
> zeroed, as C99 assures. Anybody know (for 2.95.3)?
Fortunately, I still have a 1.6.1 box using GCC 2.95.3:
--- (/dev/ttyp2) mmondor@gobot.xisop $ cc -o test test.c
--- (/dev/ttyp2) mmondor@gobot.xisop $ ./test
i1 = 4294967295, i2 = 0, p1 = 0xffffffff, p2 = 0x0
--- (/dev/ttyp2) mmondor@gobot.xisop $ cc -v
Using builtin specs.
gcc version 2.95.3 20010315 (release) (NetBSD nb3)
Program was:
#include <stdio.h>
#include <stdlib.h>
struct test {
unsigned int i1, i2;
void *p1, *p2;
};
int main(void);
int
main(void)
{
struct test t = { .i1 = -1, .p1 = (void *)0xffffffff };
printf("i1 = %u, i2 = %u, p1 = %p, p2 = %p\n",
t.i1, t.i2, t.p1, t.p2);
return EXIT_SUCCESS;
}
So it does seem to work and zero other fields
Matt
--
Note: Please only reply on the list, other mail is blocked by default.
Private messages from your address can be allowed by first asking.