[net.lang.c] Question about LINT

az@inmet.UUCP (04/09/86)

    If one has a function which is sometimes called as a procedure
(ignoring returned value) is there a way to tell lint not to
complain about this?
			Thanks in advance.
			Alex Zatsman.

steve@jplgodo.UUCP (Steve Schlaifer x3171 156/224) (04/11/86)

In article <5000041@inmet>, az@inmet.UUCP writes:
> 
>     If one has a function which is sometimes called as a procedure
> (ignoring returned value) is there a way to tell lint not to
> complain about this?

Yes, if you have something like

	int foo();

and want to ignore the return function value on a call then

	(void)foo(args);

will keep lint from complaining and also make the code clearer.
-- 

...smeagol\			Steve Schlaifer
......wlbr->!jplgodo!steve	Advance Projects Group, Jet Propulsion Labs
....group3/			4800 Oak Grove Drive, M/S 156/204
				Pasadena, California, 91109
					+1 818 354 3171

steve@gondor.UUCP (Stephen J. Williams) (04/13/86)

In article <5000041@inmet> az@inmet.UUCP writes:
>
>    If one has a function which is sometimes called as a procedure
>(ignoring returned value) is there a way to tell lint not to
>complain about this?
>                       Thanks in advance.
>                       Alex Zatsman.

caste it as void...

        (void) function (parms... )

You can even declare funcions as viod.  This is how you get "procedures"
in C, which only has functions.  Nicht war?

--Scal

robison@uiucdcsb.CS.UIUC.EDU (04/14/86)

>     If one has a function which is sometimes called as a procedure
> (ignoring returned value) is there a way to tell lint not to
> complain about this?

Cast the result to (void) when you call the function as a procedure, i.e.
	
	int foo (x)
	   int x;
	   {
	      return x;
	   }   
	
	main ()
	   {
	      (void) foo (2);
	   }

Arch D. Robison

atbowler@watmath.UUCP (Alan T. Bowler [SDG]) (04/16/86)

In article <139200026@uiucdcsb> robison@uiucdcsb.CS.UIUC.EDU writes:
>
>>     If one has a function which is sometimes called as a procedure
>> (ignoring returned value) is there a way to tell lint not to
>> complain about this?
>
>Cast the result to (void) when you call the function as a procedure, i.e.
>	
The problem with this is that you end up with very cluttered code
especially with routines like STRCPY whose return value is seldom
used.
    With the usual Unix LINT there is not much you can do about
this.  The Lint supplied with C on the Honeywell DPS-8 (the one
you get from Honeywell, not the Bell Labs C6000 (PCC) one),
there is a directive to LINT that you attach to the function
definition that defines it as a function with an optional result.
I.e. you only put this in 1 place, namely where you define the
code for the function.  If this is done, LINT will not complain
about ignoring the result of the particular function.