This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
C99 functions in stdio.h hidden when using gcc with -std=c99
- From: Markus Rinne <markus dot rinne at tut dot fi>
- To: newlib at sources dot redhat dot com
- Date: Sat, 2 May 2009 18:29:48 +0300 (EEST)
- Subject: C99 functions in stdio.h hidden when using gcc with -std=c99
Hi,
The C99 functions snprintf, vfscanf, vscanf, vsnprintf and vsscanf are not
declared in stdio.h when using gcc -std=c99. Gcc gives this kind of
warning:
foo.c:6: warning: implicit declaration of function ‘snprintf’
This is because the function declarations are enclosed in
#ifndef __STRICT_ANSI__ .
Related discussion can be found on the cygwin mailing list:
http://cygwin.com/ml/cygwin/2009-04/msg00435.html
Here is a patch to use
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L
instead.
Index: newlib/libc/include/stdio.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
retrieving revision 1.57
diff -u -r1.57 stdio.h
--- newlib/libc/include/stdio.h 4 Apr 2009 15:44:19 -0000 1.57
+++ newlib/libc/include/stdio.h 2 May 2009 14:49:46 -0000
@@ -232,6 +232,20 @@
int _EXFUN(remove, (const char *));
int _EXFUN(rename, (const char *, const char *));
#endif
+#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L
+#ifndef _REENT_ONLY
+int _EXFUN(snprintf, (char *, size_t, const char *, ...)
+ _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
+int _EXFUN(vfscanf, (FILE *, const char *, __VALIST)
+ _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+int _EXFUN(vscanf, (const char *, __VALIST)
+ _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
+int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST)
+ _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
+int _EXFUN(vsscanf, (const char *, const char *, __VALIST)
+ _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+#endif
+#endif
#ifndef __STRICT_ANSI__
#ifdef _COMPILING_NEWLIB
int _EXFUN(fseeko, (FILE *, _off_t, int));
@@ -266,8 +280,6 @@
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
int _EXFUN(siscanf, (const char *, const char *, ...)
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
-int _EXFUN(snprintf, (char *, size_t, const char *, ...)
- _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
char * _EXFUN(tempnam, (const char *, const char *));
@@ -285,24 +297,16 @@
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
-int _EXFUN(vfscanf, (FILE *, const char *, __VALIST)
- _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
int _EXFUN(viprintf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 1, 0))));
int _EXFUN(viscanf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
-int _EXFUN(vscanf, (const char *, __VALIST)
- _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
int _EXFUN(vsiprintf, (char *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
-int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST)
- _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
-int _EXFUN(vsscanf, (const char *, const char *, __VALIST)
- _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
#endif /* !_REENT_ONLY */
#endif /* !__STRICT_ANSI__ */