Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!spool.mu.edu!uunet!mcsun!ukc!acorn!osmith From: osmith@acorn.co.uk (Owen Smith) Newsgroups: comp.sys.acorn Subject: Re: More about BASIC vs. Pascal vs. C (the flame war continues !) Message-ID: <5091@acorn.co.uk> Date: 12 Feb 91 12:16:14 GMT References: <1991Feb11.105227.15182@and.cs.liv.ac.uk> Sender: osmith@acorn.co.uk Distribution: comp Organization: Acorn Computers Ltd, Cambridge, England Lines: 57 In article <1991Feb11.105227.15182@and.cs.liv.ac.uk> rkl@and.cs.liv.ac.uk writes: >I was dabbling in C on our HP UNIX boxes a while back and I was shocked at >the complete lack of warning about the following: > >hello(param1,param2) >int param1,param2; >{ > printf("Param 2 = %d\n",param2); >} > >main() >{ > hello(1); >} Your compiler did the "correct" thing. The definition of the function hello() merely acts as a declaration of hello(); since you have used a traditional C definition. Thus when you make the hello(1) call, everything looks fine to the compiler. It has no idea how many parameters hello() has or what type they should be. The fact that the function definition is in the same file makes no difference whatsoever. Indeed I would be worried if your compiler did give a warning as that would imply it was non-standard and may well cause porting problems. If you had instead written void hello ( int param1, int param2 ) { printf("Param 2 = %d\n", param2); } then in this case you would have got a warning, since an ANSI style function definition also acts as a declaration of the function with the appropriate function prototype: void hello ( int param1, int param2 ); You must remember the difference between a DEFINITION and a DECLARATION when you are programming in C. One of the things that BASIC lacks altogether is declarations. Owen (a C programmer, lost in the wilderness) The views expressed are my own and are not necessarily those of Acorn.