lint vs varargs

Philip A. Gross pag at tcsc3b2.tcsc.com
Fri Oct 27 03:18:29 AEST 1989


jcl at bdrc.UUCP (John C. Lusth) writes:

>I have a lint question. Why does lint complain about varargs stuff?

[...stuff deleted...]

>Plain old lint yields:

>    test.c(19): warning: possible pointer alignment problem

>Linting this beastie with the -c option yields:

>    test.c(18): warning: illegal pointer combination
>    test.c(19): warning: illegal pointer combination
>    test.c(19): warning: possible pointer alignment problem

>-- 
>John C. Lusth, Becton Dickinson Research Center, RTP, NC, bdrc!jcl at mcnc

John-

You may want to try placing the following comment before your function
which uses varargs.
/* VARARGS */
Most versions of lint will recognize this comment and then properly
ignore the undeclared parameters.  For example,

/* VARARGS */
char	*
make_string (astring, p1, p2, p3, p4, p5, p6, p7 p8 p9)
char	*astring;
{
	static	char	s[80];

	sprintf (s, astring, p1, p2, p3, p4, p5, p6, p7, p8, p9);

	return (s);
}

And thus a call to make_string as shown below:

print_stuff ("foo %s\n", "bar");

would produce:

foo bar

I hope this is of some assistance.  This function 'should' pass lint without
any errors.


===============================================================================
Philip A. Gross       The Computer Solution Co., Inc.       Voice: 804-794-3491
-------------------------------------------------------------------------------
INTERNET:	pag at tcsc3b2.tcsc.com
USENET:		...!tcsc3b2!pag
UUCP:		tcsc3b2!pag	(804)794-1514
ATTMAIL:	attmail!tcsc3b2!pag
-------------------------------------------------------------------------------
        The opinions expressed here are strictly mine and nobody elses.
        << I haven't heard what I have to say about that yet. >> :-)



More information about the Comp.lang.c mailing list