X3J11 Pleasanton meeting summary
Colin Plumb
ccplumb at spurge.uwaterloo.ca
Fri Oct 5 09:35:57 AEST 1990
In article <470 at taumet.com> steve at taumet.com (Stephen Clamage) writes:
> I believe the statement above attributed to Doug is not quite correct.
> The "struct foo x;" declaration uses an "incomplete type".
> Section 3.5.2.3 says that an incomplete type "may be used only when
> the size of an object of the specified type is not needed."
>
> So if you had
> struct foo x;
> size_t bar() { return sizeof(x); }
> struct foo { int i; };
> this would violate the constraint, as would
> struct foo x, y;
> void bar() { x = y; }
> struct foo { int i; };
I have to agree with Henry, though, in saying that "needed" is hoplessly
vague. Given an incomplete type Foo, here are the things I can imagine
doing with it:
extern Foo variable;
Foo variable;
{ Foo variable; ... }
Foo function(...);
Foo function(...){...}
extern Foo variable[];
Foo variable[];
sizeof(Foo);
Which are legal?
And the follwoing produce a type Bar on which the question can be
asked recursively...
typedef Foo Bar;
typedef Foo *Bar;
typedef Foo Bar(...);
typedef Type Bar(Foo,...);
typedef Foo Bar[ELEMS];
typedef struct {... Foo x; ...} Bar;
typedef union {... Foo x; ...} Bar;
For which of these is the size needed?
--
-Colin
More information about the Comp.std.c
mailing list