stdio.h patches for g++ -std=c++11
Corinna Vinschen
vinschen@redhat.com
Thu May 8 08:22:00 GMT 2014
On May 8 06:22, zosrothko wrote:
> Hi Corinna
> Le 05/05/2014 14:54, Corinna Vinschen a écrit :
> >Hi,
> >
> >On May 2 19:14, zosrothko wrote:
> >>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
> >I applied a simpler patch which just enables the C99 printf/scanf
> >functions for C++11 using the already existing declaration block.
> I have just checked out the stdio.h with the patch you made but IMO,
> it is not correct. the c++11 standard allows only the functions
> snprintf, vfscanf, vscanf, vsnprintf, and vsscanf. The patch you
> applied will allow all other functions from the existing declaration
> block. This patch will allow a c++ developper to use non standard
> c++11 functions which will preclude the portability of the code on
> another system where the strict adherence will be in place.
>
> Thus, could you rollback your change and applies the original patch.
The original patch has the downside that it adds double function
declarations. This is not feasible or, at least, it's not what we do in
any other header file.
If you want to make sure only these functions are declared, it has to be
done using matching #if expressions guarding the existing declarations.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20140508/1c8963ad/attachment.sig>
More information about the Newlib
mailing list