Xref: utzoo comp.lang.c:19557 comp.unix.questions:14458 comp.sources.wanted:7815 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pacbell!sactoh0!tree!stever From: stever@tree.UUCP (Steve Rudek) Newsgroups: comp.lang.c,comp.unix.questions,comp.sources.wanted Subject: lint won't verify printf formatting against variable types?? Keywords: lint, cc, printf_family, conquer, SysV/AT Message-ID: <328@tree.UUCP> Date: 22 Jun 89 22:32:29 GMT Organization: TREE BBS (916)-349-0385 Sacramento, Ca Lines: 29 I was surprised to discover that neither cc nor lint comments when printf formatting doesn't match variable types--I thought lint complained about everything! In other words, lint won't comment on the following: int x; long y; printf ("x=%ld y=%d", x, y); I'm trying to get a game called "conquer" to work on a Microport SysV/AT machine where ints are 16 bits rather than the 32 bits the author expected. After wrestling with variable overflow for a while, I figured the "good enough" solution would be to just change most int definitions to INT and #define INT as long. Then I would count on cc or lint to detect all the %d formatting which needed to be changed to %ld. Wrongo. cc and lint are both completely blind to the misformatting! I find that incredible. Oh, I understand that the formatting argument to printf is just a string pointer, but I'm aghast that there appears to be no easy way to detect what must be a super common coding bug! The printf family is enough of a fixture in the C language and this is a common enough sort of error that lint really should be responsible for catching this sort of misformat. Am I missing something or do I really need a custom program to detect this kind of mistake? If so, do I have to write it myself or has someone out there already written the program?? P.S. Can anyone direct me to Ed Barlow, the author of "conquer", or to the latest version? I'm hacking on version 2.2. -- ---------- Steve Rudek {ucbvax!ucdavis!csusac OR ames!pacbell!sactoh0} !tree!stever