Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Initializing automatic arrays Keywords: MPW-C, LSC, versions 3.0 Message-ID: <6683@hoptoad.uucp> Date: 6 Mar 89 01:04:32 GMT References: <9226@orstcs.CS.ORST.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Distribution: na Organization: Eclectic Software, San Francisco Lines: 28 In article <9226@orstcs.CS.ORST.EDU> sagen@nucthy.physics.orst.edu (Milt Sagen) writes: >If I compile the following code segment with MPW-C 3.0 using 'c -c file.c' >no errors are reported. However, when I compile it with LSC 3.0 it >reports an error because the array is unindexed. If I put in 6 as the >index then LSC reports an error for trying to initialize an automatic >array. > >real XFactorial( x ) > real x ; >{ > real coef[] = ( 76.18009173, -86.50532033, 24.01409822 > -1.231739516, 0.120858003e-2, 0.536382e-5 ) ; > : > : > : >} Parentheses? What are those doing there? You use curly braces to initialize aggregates. Because of the way the comma operator works, your initializer is a real number with the value 0.536382e-5. Any compiler that lets you assign that to an array/pointer without a type cast is confused. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "When the writer becomes the center of his attention, he becomes a nudnik. And a nudnik who believes he's profound is even worse than just a plain nudnik." -- Isaac Bashevis Singer