Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!usc!apple!oliveb!tymix!cirrusl!dhesi%cirrusl From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: main() linkage Message-ID: <1122@cirrusl.UUCP> Date: 28 Nov 89 01:18:57 GMT References: <2387@stl.stc.co.uk> <744@lakart.UUCP> <0175@sheol.UUCP> <11621@smoke.BRL.MIL> <7744@cdis-1.uucp> <11665@smoke.BRL.MIL> Sender: news@cirrusl.UUCP Reply-To: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Organization: Cirrus Logic Inc. Lines: 33 What is erroneous programming practice? One overly simple definition is "programming practice that violates the ANSI C standard". Which is not a very useful definition when considering code that was written before the ANSI C standard came into being. I have seen the usual use of printf to be considered an error waiting to be fixed. (I have even seen Ritchie as being quoted as saying something like this.) But if K&R defined the C programming language in a certain way, and that definition required printf to be used in a certain way, and if millions of lines of existing *correctly working code* uses printf, thow can that usage possibly be erroneous? On the other hand, existing code can stop working through no fault of its own, if compilers are changed to no longer compile it correctly. For example, if compiler writers suddenly begin to use a linkage convention that varies from function to function, printf will no longer work. That does not mean that the original C code was erroneous. Rather, it is the compiler that is no longer compiling C code the way it used to be compiled. So was it portable to declare main() to return void? As always, portability depends on your universe. Within the universe of C implementations that supported the language as defined by K&R, which was roughly equivalent to the universe of existing C implementations, it was always portable to declare main() to return anything you wanted, provided you always existed by calling exit. *That has not changed*. What has changed is universe of existing C implementations, and it has changed because the meaning of "C" has changed. Rahul Dhesi UUCP: oliveb!cirrusl!dhesi