Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!csn!boulder!agcsun!jackm From: jackm@agcsun.UUCP (Jack Morrison) Newsgroups: comp.lang.c Subject: Re: Why didn't ANSI make initialisation consistent ???? Message-ID: <959@agcsun.UUCP> Date: 25 Apr 91 21:15:49 GMT References: <1991Apr24.141206.18103@grep.co.uk> Reply-To: jackm@agcsun.UUCP (Jack Morrison) Organization: Ampex VSD Golden Engineering, Golden, CO Lines: 40 In article <1991Apr24.141206.18103@grep.co.uk> vic@grep.co.uk (Victor Gavin) writes: >I (after many, many years of C programming) found that I couldn't perform what >I considered to be a reasonable assignment command. >I traced it back to my use of > char *fred = "bert" >being the same as > char fred[] = {'b', 'e', 'r', 't', '\0'} We'll assume ;-) you really meant that it's similar to char _fred[] = {'b', 'e', 'r', 't', '\0'}; char *fred = _fred; >Which made me believe that I could use the following code: > struct bert { int a, b; } > struct fred { struct bert *abc; } blip = { {1,1} }; > >[[ie That the compiler will place the data for the structure into one of the >data segments and then place it's address into the pointer variable.]] >Of course none of my compilers liked this. It's not so much an *initialization* inconsistency, but the limitation that you can't write a constant structure value the same way you can a constant string. For example, it would also be nice to be able to call void foo(struct bert b); [NOT "struct bert *b", mind you] as foo( {1,1} ); or, if the compiler would like a little more help, foo( (struct bert){1,1} ); I have no answer as to whether anyone official has considered it before... -- "How am I typing? Call 1-303-279-1300" Jack C. Morrison Ampex Video Systems 581 Conference Place, Golden CO 80401