questions from using lint

Mark DeWitt dewitt at cca.UUCP
Wed Apr 9 10:12:13 AEST 1986


*** REPLACE THIS LINE WITH YOUR MESSAGE ***
I have three questions, the first of which was only brought to my
attention by lint, not caused by it.  The code in question works under BSD4.2
on both vaxes and suns.

1.  I have code with declarations that look like the following:
	struct tm *zulu, *gmtime();

but I forgot to #include <sys/time.h> at the top.  Pretty careless,
but what is remarkable is that I never noticed until I ran lint on
it.  WHY DID THIS COMPILE SUCCESSFULLY?  The only other headers I
included were ctype.h and stdio.h, neither of which includes anything
else.  The lint message was:

warning: structure tm never defined

2.  With the following code--
	static int page;

	ioctl(0, SOMEINTEGER, (char *)&page);
		or
	ioctl(0, SOMEINTEGER, (char *)(&page));

lint says:

warning: illegal pointer combination.

This doesn't make sense to me.  For one thing, ioctl's arguments are
defined in the manual as:
	ioctl(int d, int request, char *argp)

For another thing, the C Reference Manual says (Section 14.4):

	"It is guaranteed that a pointer to an object of a given size
	may be converted to a pointer to an object of smaller size and
	back again without change."

So why can't I cast the address of a static integer into a pointer to
a character?  If I don't cast all such arguments of disparate types to
char *'s then lint complains about "arg n not declared consistently" or
something like that.

3.  How do you get lint to shut up about variable numbers of arguments
with stdio functions like printf, scanf, etc.?  I tried using /*VARARGS*/
right, left, and sideways to no avail.  The doc is not great, but you
knew that already.

After three years of C programming I'm just starting to use lint, so
please no negative reinforcement by flaming about how stupid my questions
are, lest I give up on it entirely :-).
-- 
"We like your attitude, but what are you doing?"



More information about the Comp.lang.c mailing list