This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: g++: -ansi flag makes snprintf() unavailable?
On 2010/01/19 8:06 PM, Eric Blake wrote:
> Using -ansi generally says that you want the headers to expose ONLY the
> interfaces mentioned in the C89 standard. But C89 did not describe
> snprintf, hence your compilation failure.
Actually, it looks like -ansi means something slightly different when
used in C++ mode. According to the gcc manual, -ansi in C++ mode is
equivalent to -std=c++98 , which in English means "use the 1998 ISO C++
standard plus amendments".
Googling "1998 ISO C++ standard", I was able to find something that
looks like an official ISO document which covers this standard, and its
<cstdio> library does _not_ mention snprintf(), just as you stated.
Thus, it appears that in this case the Cygwin compiler's behaviour is
correct (i.e. to treat snprintf as undefined under -ansi), while the
Debian compiler has it wrong. Interesting!
> In the meantime, either don't use snprintf without declaring it by hand,
> or else don't use -ansi, since they are obviously not compatible in the
> current state of the headers.
Will do. Thanks for your time.
-SM
--
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple