Niggling problem with enumerated types in Turbo C++

Christopher R Volpe volpe at camelback.crd.ge.com
Wed Jun 26 22:47:54 AEST 1991


In article <44348 at fmsrl7.UUCP>, wreck at 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 at crd.ge.com



More information about the Comp.lang.c mailing list