🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2650
From: Efraim Mostrom
Date: Fri, 11 Aug 2000 00:00
51 lines
2658 bytes
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
Technical Details
Message-ID: <clcm-20000811-0005@plethora.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f65d0,99e7fdc5e0986bd,start
X-Google-Attributes: gidf65d0,public
X-Google-Thread: 10aedf,99e7fdc5e0986bd,start
X-Google-Attributes: gid10aedf,public
X-Google-Thread: 100850,99e7fdc5e0986bd,start
X-Google-Attributes: gid100850,public
From: "Efraim Mostrom" <mostrom.nospam@iname.com>
Subject: ANSI-C/GCC/LCLINT snprintf() ??
Date: 2000/08/11
Message-ID: <clcm-20000811-0005@plethora.net>
X-Deja-AN: 657318242
X-Old-trace: nntpserver.swip.net 966017682 212.151.235.171 (Fri, 11 Aug 2000 20:14:42 MET DST)
Content-Transfer-encoding: 8bit
Approved: clc@plethora.net
X-Sender: unknown@d212-151-235-171.swipnet.se
X-Priority: 3
Content-Type: text/plain; charset="iso-8859-1"
X-Mimeole: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: abuse@plethora.net
X-Trace: 966030997 gemini.plethora.net 72534 clcm@205.166.146.1
Organization: A Customer of Tele2
X-Msmail-priority: Normal
Mime-Version: 1.0
X-Old-complaints-to: news-abuse@swip.net
X-Clcm-spamtrap-trap: http://www.alladvantage.com/
X-Mime-autoconverted: from quoted-printable to 8bit by herd.plethora.net id NAA28197
Newsgroups: comp.lang.c.moderated,gnu.gcc,linux.dev.c-programming
Originator: clcm@plethora.net (Comp Lang C'Moderated)