This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

1.7: snprintf() with gcc -std=c99: warning about implicit declaration


Hello,

compiling C programs which use snprintf function with gcc option -std=c99 gives a warning about implicit declaration of snprintf.
Should snprintf be declared by including stdio.h when using C99 standard?


For example, with the following program in snprintf.c:

#include <stdio.h>

int main(void)
{
	char buf[10];
	snprintf(buf, 10, "%i", 0);
	return 0;
}

Compiling with gcc-3 and gcc-4 gives these warnings:

$ gcc-3 -std=c99 snprintf.c
snprintf.c: In function `main':
snprintf.c:6: warning: implicit declaration of function `snprintf'

$ gcc-4 -std=c99 snprintf.c
snprintf.c: In function ‘main’:
snprintf.c:6: warning: implicit declaration of function ‘snprintf’
snprintf.c:6: warning: incompatible implicit declaration of built-in function ‘snprintf’

Here are package versions checked with cygcheck -c:
cygwin: 1.7.0-46
gcc-core: 3.4.4-999
gcc4-core: 4.3.2-2

It seems gcc defines __STRICT_ANSI__ when passed the -std=c99 option and the declaration of snprintf is enclosed in
#ifndef __STRICT_ANSI__
in stdio.h.


Markus Rinne

Attachment: cygcheck.out
Description: Text document

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]