Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!seismo!rochester!pt.cs.cmu.edu!cadre!pitt!darth!gary From: gary@darth.UUCP Newsgroups: comp.lang.c Subject: Re: Problem with Microsoft C V4.0 Message-ID: <191@darth.UUCP> Date: Tue, 24-Mar-87 22:03:40 EST Article-I.D.: darth.191 Posted: Tue Mar 24 22:03:40 1987 Date-Received: Sat, 28-Mar-87 05:30:56 EST References: <5397@brl-adm.ARPA> Reply-To: gary@darth.UUCP (Gary Wisniewski) Organization: Darth Software, Allison Park, Pa. 15101 Lines: 59 Summary: Pros and cons of function prototypes In article <5397@brl-adm.ARPA> Schauble@mit-multics.arpa (Paul Schauble) writes: >I've recently acquired Microsoft C version 4.0, replacing Lattice >version 2.15. In most aspects, it's a considerable improvement, and I >wouldn't give up Codeview for anything else I've seen. However, I just >had something happen that has badly soured me on the compiler. The >problem is this > >Within one file I have the function declaration > > void bgunlink_transaction_record (bgfile, client, transaction) > BGFILE *bgfile; > struct tclient_rec *client; > struct ttransaction_rec *transaction; > { > .... > } > >The type BGFILE and the structures are correctly declared prior to this. >Later in the file I have the statement > > bgunlink_transaction_record (&bgfile, &client_rec, rec, &transaction); > >Note that they don't match in number or types of arguments. When >compiling with /W3 for maximum checking, the compiler SAYS NOT A WORD >ABOUT THIS. >[...] It is not always desirable to have the compiler assume that a previously declared function is prototyped. For example: void wishy_washy_func(code, optional_arg); If the second argument in this function is optional (that is, present for some values of "code" and absent for others), the following are perfectly acceptable: wishy_washy_func(OPTION_A); wishy_washy_func(OPTION_B, i); So long as there is logical consistency, no problems occur. Of course, this is a contrived example, and there is no way for the compiler to typecheck uses. I don't particularly advocate such constructions, but wonder whether such considerations were in mind when Microsoft implemented their compiler. With Lattice, the above is still possible if a prototype such as: wishy_washy_func(enum ww_option, ...); is defined. This is probably better, since optional arguments are rarer and often compromise portability. I would be curious if anyone else can post a case where default prototyping is undesirable. Gary J. Wisniewski uucp: {allegra, bellcore, cadre}!pitt!darth!gary "Searching for truth is more rewarding than finding it."