[comp.lang.c] strange behaviour of lint?

ccea3@rivm.UUCP (Adri Verhoef) (05/05/89)

$ cat c.c
main()
{
	(void) exit(0);

	/* Make lint happy, preventing following message:
	 * "warning: main() returns random value to invocation environment"
	 */
	return 0;
}
$ lint c.c


==============
value type declared inconsistently
    exit   	llib-lc(46) :: c.c(3)
$ sed -n 46p /usr/lib/llib-lc
void	exit(s) {}
$ exit

My question: Is lint wrong, or am I misusing "(void)"?

PS. lint complains about any void function, not just exit().

--
19:89 - TIME TO WAKE UP!

c08_d107@jhunix.HCF.JHU.EDU (Eric B. Hymowitz) (05/07/89)

In article <1325@rivm05.UUCP> ccea3@rivm.UUCP (Adri Verhoef) writes:

program deleted... hope you don't mind...
in effect, it has a main() with one line: exit(0).
>
>==============
>value type declared inconsistently
>    exit   	llib-lc(46) :: c.c(3)
>$ sed -n 46p /usr/lib/llib-lc
>void	exit(s) {}
>$ exit
>
>My question: Is lint wrong, or am I misusing "(void)"?

as far as i (and my friends) can tell, lint prefers
''return 0'' to exit(0).  that may solve some problems...

also, (at the risk of repeating other people), lint must be taken
with a teaspoon of salt. :)

it also complains if you don't use the values returned from functions
like printf.

there's nothing wrong with exit(0) as opposed to return 0, if you
don't mind lint complaining.

--eric
disclaimer:  my disdain for capital letters is just that.  it does not
imply a disliking toward any person, object, or other proper noun or
adjective beyond the extent that it requires capitalization.

disclaimer: my idiocies are mine alone.  i speak for no idiots other than
myself.  any idiot who wishes me to speak for him may inquire of me;
if any idiots take my proposal, their names shall be listed with mine.

gwyn@smoke.BRL.MIL (Doug Gwyn) (05/08/89)

In article <1325@rivm05.UUCP> ccea3@rivm.UUCP (Adri Verhoef) writes:
>My question: Is lint wrong, or am I misusing "(void)"?

You're not declaring the exit() function, so the default rule applies,
namely it is assumed to be a function of indeterminate arguments
returing int.  Since that's not correct (exit() is void-valued),
"lint" properly complains about the inconsistency.

decot@hpisod2.HP.COM (Dave Decot) (05/09/89)

Since you have not provided an external declaration for the function exit(),
lint assumes that in your program, the following declaration is implied:

    extern int exit();

When lint checks the lint library for libc, however, it sees that there it
is declared to return void.

You can get lint to stop this message by adding:

     extern void exit();

before you first use exit().

The function perror() has a similar problem.

NOTE: For ANSI C compilation systems, ignore all of the previous, and use

    #include <stdlib.h>

instead.