Article View: comp.lang.c.moderated
Article #2651Re: ANSI-C/GCC/LCLINT snprintf() ??
From: Oleg Goldshmidt
Date: Mon, 14 Aug 2000 00:00
Date: Mon, 14 Aug 2000 00:00
51 lines
2372 bytes
2372 bytes
"Efraim Mostrom" <mostrom.nospam@iname.com> writes:
> Hi!
>
> Short code for exemple:
>
> #include <stdio.h>
> int main(int * argc, char * argv[]) {
How come gcc does not complain about the type of argc? It should be
int.
> char *buf[1024];
Should be "char buf[1024]", I suppose
> extern int snprintf(char *, int, const char *, ...);
The second argument to snprintf() is of type size_t, not int.
Any self-respectiung lint should complain that argc is not used in
your program.
Does it help if you fix those things?
By the way, just -Wall -pedantic -ansi might not be strict enough
(-Wall is a misnomer). You might want to use
-W \
-pedantic \
-Wall \
-Wtraditional \
-Wshadow \
-Wid-clash-32 \
-Wpointer-arith \
-Wcast-qual \
-Wcast-align \
-Wconversion \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wnested-externs \
to get more warnings and an approximation to a lint with gcc.
--
Oleg Goldshmidt <ogoldsh@NOSPAM.netvision.net.il>
"... We work by wit, and not by witchcraft;
And wit depends on dilatory time." [Shakespeare]
--
comp.lang.c.moderated - moderation address: clcm@plethora.net
Technical Details
Message-ID:
<clcm-20000814-0005@plethora.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<clcm-20000811-0005@plethora.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10aedf,99e7fdc5e0986bd X-Google-Attributes: gid10aedf,public X-Google-Thread: f65d0,99e7fdc5e0986bd X-Google-Attributes: gidf65d0,public X-Google-Thread: 100850,99e7fdc5e0986bd X-Google-Attributes: gid100850,public From: Oleg Goldshmidt <ogoldsh@NOSPAM.netvision.net.il> Subject: Re: ANSI-C/GCC/LCLINT snprintf() ?? Date: 2000/08/14 Message-ID: <clcm-20000814-0005@plethora.net> X-Deja-AN: 658261882 X-Old-trace: news.netvision.net.il 966186724 11314 62.0.156.173 (13 Aug 2000 17:12:04 GMT) Approved: clc@plethora.net References: <clcm-20000811-0005@plethora.net> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@plethora.net X-Trace: 966284179 gemini.plethora.net 72520 clcm@205.166.146.1 Organization: Speaking for myself Mime-Version: 1.0 X-Old-complaints-to: abuse@netvision.net.il User-Agent: Gnus/5.0806 (Gnus v5.8.6) XEmacs/21.1 (Bryce Canyon) X-Clcm-spamtrap-trap: http://www.alladvantage.com/ Newsgroups: comp.lang.c.moderated,gnu.gcc,linux.dev.c-programming Originator: clcm@plethora.net (Comp Lang C'Moderated)