stdio.h patches for g++ -std=c++11

zosrothko zosrothko@orange.fr
Fri May 2 13:40:00 GMT 2014


Hi

This is a patch for exposing the new stdio functions added by the c++11 
standard. Without this patch the snprintf for example is not exposed as

$ cat hello.cpp
#include <cstdio>

int main(int argc, char** argv) {
char buf[24];
snprintf(buf, 2, "", 2);
return 0;
}

$ g++ -std=c++11 hello.cpp
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:4:30: erreur: ‘snprintf’ was not declared in this scope
snprintf("", 2, "", 2);

$ g++ -xc++ -std=c++11 -dM -E - < /dev/null | sort | grep ANSI
#define __STRICT_ANSI__ 1

$ g++ -dM -E - < /dev/null | sort | grep ANSI

$

Regards



-------------- next part --------------
Index: newlib/libc/include/stdio.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
retrieving revision 1.68
diff -u -r1.68 stdio.h
--- newlib/libc/include/stdio.h	6 Jan 2014 20:59:38 -0000	1.68
+++ newlib/libc/include/stdio.h	2 May 2014 13:18:04 -0000
@@ -232,6 +232,23 @@
 off_t	_EXFUN(ftello, ( FILE *));
 #endif
 #endif
+
+#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+#ifndef _REENT_ONLY
+int	_EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...)
+               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
+int	_EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST)
+               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+int	_EXFUN(vscanf, (const char *, __VALIST)
+               _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
+int	_EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST)
+               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
+int	_EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
+               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+#endif /* !_REENT_ONLY */
+#endif
+
+
 #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
 #ifndef _REENT_ONLY
 int	_EXFUN(asiprintf, (char **, const char *, ...)


More information about the Cygwin-patches mailing list