| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-0.9 required=5.0 tests=AWL,BAYES_00 |
| X-Spam-Check-By: | sourceware.org |
| Date: | Wed, 4 Apr 2012 15:32:20 +0200 |
| From: | Denis Excoffier <cygwin AT Denis-Excoffier DOT org> |
| To: | cygwin AT cygwin DOT com |
| Subject: | snprintf() with g++ -std=c++98: error: 'snprintf' was not declared in this scope |
| Message-ID: | <20120404133244.GA2056@qp9482> |
| MIME-Version: | 1.0 |
| User-Agent: | Mutt/1.5.21 (2010-09-15) |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
Hello,
It could be that snprintf() is not properly declared in <stdio.h>.
Take the following foo.c:
% cat foo.c
#include <stdio.h>
int main(void)
{
char buf[10];
snprintf(buf, 10, "%i", 0);
return 0;
}
%
In C, perhaps after a remark from Markus
(http://sourceware.org/ml/cygwin/2009-04/msg00435.html), no compiler
message is produced:
% gcc -xc -std=c90 -c foo.c
% gcc -xc -std=c99 -c foo.c
%
On the other hand, for C++, a compiler message is produced:
% gcc -xc++ -std=c++98 -c foo.c
foo.c: In function 'int main()':
foo.c:6:28: error: 'snprintf' was not declared in this scope
%
% gcc -xc++ -std=c++0x -c foo.c
foo.c: In function 'int main()':
foo.c:6:28: error: 'snprintf' was not declared in this scope
%
Replacing <stdio.h> with <cstdio> produces the same result.
Shouldn't snprintf() (and vsnprintf() etc.) be declared in
<stdio.h> also for the C++ language/standard, especially c++0x?
Regards,
Denis Excoffier.
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |