Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cca!mirror!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: IBM RT compiler weirdness Message-ID: <1021@haddock.ISC.COM> Date: Mon, 31-Aug-87 11:32:48 EDT Article-I.D.: haddock.1021 Posted: Mon Aug 31 11:32:48 1987 Date-Received: Fri, 4-Sep-87 05:24:03 EDT References: <261@calyx.UUCP> <8258@mimsy.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 27 In article <8258@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >Try including > #ifdef lint > thing_to_call_main() { exit(main(0, (char **)0); } > #endif >somewhere in the program so that lint will compare the return value >of main with the argument type for exit(). Interesting idea. You should also declare "extern void exit();" (except on BSD systems where exit is misdeclared in llib-lc!) to minimize the number of new warnings. Also, some of us consider it perfectly valid practice to define main() with no arguments and/or no return value. This would elicit a warning or two if your suggested function is in place. I'd say the best thing to do is to add it to lint. There is already a partial precedent, in that some versions of lint recognize "main" as a special case so they can warn about falling off the bottom of the function. In my view, there are nine correct models for main, represented by the Cartesian product of { "main()", "main(argc, argv)", "main(argc, argv, envp)" } with { "void main()", "int main() { ... }", "int main() { ... return VALUE; }".% Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint %In the two cases where main does not return a value, it is presumed that it does not return at all. It would be nice if lint would verify this, too, but that's a separate issue.