Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!asuvax!stjhmc!p12.f56.n114.z1.fidonet.org!Chris.Gehlker From: Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C ?: struct bug Message-ID: <30466.274B6654@stjhmc.fidonet.org> Date: 22 Nov 90 05:44:22 GMT Sender: ufgate@stjhmc.fidonet.org (newsout1.26) Organization: FidoNet node 1:114/56.12 - AZ MAC UG, Phoenix AZ Lines: 37 hairston@henry.ece.cmu.edu (David Hairston) writes: > [bernard@boulder.Colorado.EDU (Bernie Bernstein) writes:] > [] I don't know if this is common knowledge, but I found a bug in the > [] Think C compiler concerning the ?: operator and structs. It doesn't > [] accept the following program segment: > [] > [] ... > [] > [] typedef struct { > [] long a; > [] long b; > [] } MY_TYPE; > [] > [] ... > [] > [] foo(short x) > [] { > [] MY_TYPE id1,id2,id3; > [] > [] id1 = x ? id2 : id3; /* Illegal operation on struct/union */ > > my guess is that you've declared id1 to have allocated space and so > you can't change it's address as implied above. i believe you want: > > MY_TYPE *id1, id2, id3; > ... > id1 = x ? &id2 : &id3; I guess he wants id1 == x ? &id2 : &id3; ^^ -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org