This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

snprintf() with g++ -std=c++98: error: 'snprintf' was not declared in this scope


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]