Re: mutually referential (Pg 140 K&R2)



Dave Thompson wrote:
>
> On Sat, 23 Apr 2005 15:23:02 +1000, Russell Shaw
> <rjshawN_o@xxxxxxxxxxxxxxxxxxxxx> wrote:
> <snip>
> > struct s *p declares p using an incomplete struct s type, which is later completed
> > with struct s {...}.
>
> Correct.
>
> > Incomplete types apply only to curly bracket things like
> > enums, unions, and structs iirc.
>
> YDNRC.
>
> Forward declared struct and union tags are incomplete, until (the end
> of) the full definition (if any). You can't forward declare an enum
> tag; technically an enum type is incomplete from its type-specifier to
> its closing brace, but this only means you can't use sizeof(enum foo)
> as one of its own values which seems pretty silly anyway.

I think you can. The enum type is complete,
that is to say that it's type size is known at compile time,
even if it's values haven't been specified.

/* BEGIN new.c */

#include <stdio.h>

int main(void)
{
enum foo {Zero = sizeof (enum foo), One};
enum bar;

printf("sizeof (enum bar) is %lu bytes\n.",
(long unsigned)sizeof(enum bar));
return One - Zero - 1;
}

/* END new.c */


--
pete
.



Relevant Pages

  • Re: Type alias in C#
    ... Not all value types are structures, for example, enum. ... Lutz Roeder's refector declares Enum as a 'public ... here is that the term "struct" and "value type" are being passed around as synonomous -- which they really aren't. ... An enum is a class that derives from System.Enum. ...
    (microsoft.public.dotnet.languages.csharp)
  • [PATCH][v4][1/24] Add core InfiniBand support (public headers)
    ... +struct ib_fmr_pool_param { ... +enum ib_device_cap_flags { ... specifies the QP attributes to modify. ... The protection domain associated with the memory region. ...
    (Linux-Kernel)
  • [PATCH][v5][1/24] Add core InfiniBand support (public headers)
    ... +struct ib_fmr_pool_param { ... +enum ib_device_cap_flags { ... specifies the QP attributes to modify. ... The protection domain associated with the memory region. ...
    (Linux-Kernel)
  • [PATCH][v3][1/21] Add core InfiniBand support (public headers)
    ... +struct ib_fmr_pool_param { ... +enum ib_device_cap_flags { ... specifies the QP attributes to modify. ... The protection domain associated with the memory region. ...
    (Linux-Kernel)
  • Re: Updating the Java language bindings
    ... Once the server receives the struct, ... I think that IDL with a couple of enhancements could be use to ... the enum. ... That's why I'm using the string value of the enum rather than the ...
    (comp.object.corba)