Path: utzoo!news-server.csri.toronto.edu!rutgers!uwm.edu!cs.utexas.edu!uunet!mcsun!ukc!axion!tharr!gtoal From: gtoal@tharr.UUCP (Graham Toal) Newsgroups: comp.sys.acorn Subject: Re: Another query about the behaviour of the C compiler (version 3.00) Keywords: C, Acorn C compiler Message-ID: <1925@tharr.UUCP> Date: 9 Mar 91 09:53:04 GMT References: Reply-To: gtoal@tharr.UUCP (Graham Toal) Organization: Power Microsystems Ltd Lines: 44 In article vanaards@p4.cs.man.ac.uk (Steven van Aardt) writes: : : Still developing this project of mine. The previous bug I reported wasn't :a bug at all - in fact just bad programming, I was clobbering one of my :data structures, thanks to Arthur Norman (Codemist Ltd, aka Norcroft), for :pointing this out to me. (In future I'll be more cautious about declaring that :I've found a bug - ref reading from system devices kbd: (which actually was a :bug in the system devices module!). It's OK - we won't say we told you so ;-) : : Well here's another problem I've come across, the include files are okay, :so I needn't include them here. What's interesting is the output I've got :from the compiler - all I've done here is type *spool cbug (opps sorry :that should read 'coutput'). OKay so I know that my source has a few :bugs - but why did the compiler give-up on me ? : : :---------------------- Here's the output ----------------------------------- : :$.!Hypertext *cc -gfvl -c -zpc1p2s0v3z0 rl :Norcroft RISC OS ARM C vsn 3.00 [Jul 12 1989] :"c.rl", line 11: Error: expected ';' or ',' - inserted ';' before 'struct' :"c.rl", line 23: Serious error: type 'char' inconsistent with 'struct' :"c.rl", line 45: Error: 'return': implicit cast of pointer to non-equal pointer : :Illegal address (e.g. wildly outside array bounds) This is the only bug I've found in NorCroft, and it only happens with a wrong program: in Ansi, if you give a spec for a procedure which has a struct as a parameter, and then actually declare the struct type *after* the declaration, - when you come to the body of the procedure you will get a type check error on the struct. The solution is to move the struct type declaration to above the external procedure/forward declarations. The annoying thing is that this was legal in k&r, so many existing programs do it :-( I'm not sure this is your problem, but I thought it was worth telling people anyway. Graham. -- (* Posted from tharr.uucp - Public Access Unix - +44 (234) 720202 *)