Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!cmcl2!phri!roy From: roy@phri.UUCP (Roy Smith) Newsgroups: comp.lang.c Subject: How to initialize unions Message-ID: <3742@phri.UUCP> Date: 4 Apr 89 21:03:51 GMT Organization: Public Health Research Institute, NYC, NY Lines: 27 I've got a structure which looks like: struct ident { char *name; int type; union { double f; int i; } value; }; and I want to initialize the name, type, and value.i elements of an array of them them at compile time. Trying the obvious: struct ident idlist[] = { {"foo", KEYWORD, KW_FOO}, {"bar", KEYWORD, KW_BAR}, {"baz", KEYWORD, KW_BAZ} }; draws an error from the compiler, "operands of = have incompatible types" for each of the 3 lines. Is there any way to do what I want to do? -- Roy Smith, System Administrator Public Health Research Institute {allegra,philabs,cmcl2,rutgers,hombre}!phri!roy -or- roy@phri.nyu.edu "The connector is the network"