Initialized bitfileds - help me read

Karl Heuer karl at haddock.ima.isc.com
Wed Mar 22 03:37:15 AEST 1989


In article <1989Mar17.175208.1064 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>Initialization of bitfields is not special in any way in ANSI C -- they are
>ordinary structure members for this purpose.

Except that "All unnamed structure or union members are ignored during
initialization" (3.5.7), and I believe that only bitfields can be unnamed.

So, what is the correct way to initialize an object of type
	struct alpha { int a; struct beta { int :3; } b; int c; }
, where one of the members is a struct with no initializable members?  Does
the initializer {1,2} initialize a and c?  Or is {1,{},2} the proper (fully-
bracketed) syntax?

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.std.c mailing list