🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2652

Re: ANSI-C/GCC/LCLINT snprintf() ??

#2652
From: Warren Dale
Date: Mon, 14 Aug 2000 00:00
58 lines
2547 bytes
On 11 Aug 2000 21:56:37 GMT, "Efraim Mostrom"
<mostrom.nospam@iname.com> wrote:

>Hi!
>
>Short code for exemple:
>
>#include <stdio.h>
>int main(int * argc, char * argv[]) {
>    char *buf[1024];
>    if ((snprintf(buf,1024,"string : %s string2 : %s",argv[1],argv[2])) == -1) {
>            fprintf(stderr,"main : error while snprintf() \n");
>            exit(1);
>    }
>    fprintf(stdout,"buf = %s\n",buf);
>    return 0;
>}
>
>gcc -Wall -ansi -pedantic -O -g main.c -o proggy
>
>Errors from gcc: snprintf() implicitly defined.
>
>I then add to the source:
>
>extern int snprintf(char *, int, const char *, ...);
>
>I compile it again with same flags, and gcc takes it.
>
>But when I in LINUX RH6.1 run lclint I get a parse error with:
>
>extern int snprintf(char *, int, const char *, ...);
>
>I know that snprintf() is not ANSI, but when I
>#define _BSD_SOURCE it gets through gcc without problem,
>but lclint still talks about undefined function.
>
>I do not want to use #define _BSD_SOURCE or #define _GNU_SOURCE
>I just want to explicitly declare:
>
>extern int snprintf(char *, int, const char *, ...);
>
>Is lclint buggy or am I missing something here?
>
>Very, very thankfull for help. By defining the non ANSI functions myself
>I can keep track of them if I would like to port the program.
>
>Thanks in advance,
>
>/Efraim
>
>-- 
>Remove nospam from my adress to reply.
>-- 
>comp.lang.c.moderated - moderation address: clcm@plethora.net

#include <stdarg.h>
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net
Technical Details
Message-ID: <clcm-20000814-0007@plethora.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <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: wdale@ozemail.com.au (Warren Dale)
Subject: Re: ANSI-C/GCC/LCLINT snprintf() ??
Date: 2000/08/14
Message-ID: <clcm-20000814-0007@plethora.net>
X-Deja-AN: 658262121
X-Old-trace: ozemail.com.au 966225318 203.108.14.222 (Mon, 14 Aug 2000 13:55:18 EST)
Distribution: world
Approved: clc@plethora.net
References: <clcm-20000811-0005@plethora.net>
X-Complaints-To: abuse@plethora.net
X-Trace: 966284224 gemini.plethora.net 72533 clcm@205.166.146.1
Organization: OzEmail Ltd, Australia
Newsgroups: comp.lang.c.moderated,gnu.gcc,linux.dev.c-programming
X-Clcm-spamtrap-trap: http://www.alladvantage.com/
Originator: clcm@plethora.net (Comp Lang C'Moderated)