Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Niggling problem with enumerated types in Turbo C++ Message-ID: <20912@crdgw1.crd.ge.com> Date: 26 Jun 91 12:47:54 GMT References: <44348@fmsrl7.UUCP> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Distribution: usa Lines: 32 In article <44348@fmsrl7.UUCP>, wreck@fmsrl7.UUCP (Ron Carter) writes: |>This program fragment will not compile in Turbo C++. |>It issues error messages for lines 8 and 9. So far |>as I can determine, I have defined the enumerated |>types sol_type and sol_state correctly, but the |>compiler does not appear to recognize them inside |>the structure definition. Can anyone tell me what |>I'm doing wrong? E-mail please. |>--------------- Program frag follows -------------------- |>enum sol_type { OnOff, VFS }; |>enum sol_state { Const, Var }; |> |>struct s_sol_label { |> int col, wid; /* Column to put it in, and its width */ |> char *lab1; /* Label line 1 */ |> char *lab2; /* Label line 2 */ |> sol_type stype; |> sol_state sstate; |> }; you have to say "enum sol_type stype;" within that structure definition. "sol_type" (this applies to sol_state too, of course) is not a type all by itself, it's just a tag. If you want it to become a type, use a typedef. E.g.: typedef enum [optional tag here] {OnOff, VFS} sol_type; Chris ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com