Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!bbn.com!nic!chaos.cs.brandeis.edu!chaos!phils From: phils@chaos.cs.brandeis.edu (Phil Shapiro) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C ?: struct bug Message-ID: Date: 19 Nov 90 20:47:21 GMT References: <29910@boulder.Colorado.EDU> <1990Nov18.103920.24295@nada.kth.se> Sender: @chaos.cs.brandeis.edu Organization: Symantec Corp. Lines: 49 In-Reply-To: d88-jwa@dront.nada.kth.se's message of 18 Nov 90 10:39:20 GMT In article <1990Nov18.103920.24295@nada.kth.se> d88-jwa@dront.nada.kth.se (Jon W{tte) writes: In article hairston@henry.ece.cmu.edu (David Hairston) writes: >[bernard@boulder.Colorado.EDU (Bernie Bernstein) writes:] >[] 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; Well, this is something else. You should be able to assign structs to each other. This should result in a bitwise copy. Like, id1 = id2 ; /* This is BlockMove ( id2 , id1 , sizeof ( id1 ) ) */ > -dave- >hairston@henry.ece.cmu.edu Now, you should know that Think C isn't ANSI C, porting that beast ;-) This is considered by us (at Symantec) to be a bug. More specifically, it is an area where we are non-ANSI compiliant. While the current version does not claim to be fully compliant, the next major release will be, and the above code (using ?) will work. Currently structures can be used in assignment or in function return. BTW, id1 = *( x ? &id2 : &id3); works (if you don't mind REAL ugly code :-) -phil -- Phil Shapiro Technical Support Analyst Language Products Group Symantec Corporation Internet: phils@chaos.cs.brandeis.edu