delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/04/02/21:28:37

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Authentication-Results: msg-ip2.usc.edu; dkim=neutral (message not signed) header.i=none
X-IronPort-AV: E=Sophos;i="4.87,396,1363158000";
d="scan'208";a="1172092123"
Date: Tue, 02 Apr 2013 18:07:35 -0800
From: Mikhail Ryazanov <ryazanov AT usc DOT edu>
Subject: snprintf not found
Sender: ryazanov AT usc DOT edu
To: djgpp AT delorie DOT com
Message-id: <515B8EE7.4060603@usc.edu>
Organization: USC
MIME-version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107
Thunderbird/17.0.2
Reply-To: djgpp AT delorie DOT com

Hello!

I have a problem compiling programs with snprintf (actually, vsnprintf) 
function. Although it is described in the documentation 
[http://www.delorie.com/djgpp/doc/libc/libc_732.html] and is present in 
the provided header files, a simple test program

#include <stdio.h>
int main(void) {
   return snprintf(NULL, 0, "%d", 123);
}

fails to compile both in C++ mode:

... error: 'snprintf' was not declared in this scope

(playing with <cstdio> and various possible scopes does not help) and in C:

... warning: implicit declaration of function 'snprintf' 
[-Wimplicit-function-declaration]
... warning: incompatible implicit declaration of built-in function 
'snprintf' [enabled by default]
... undefined reference to `snprintf'

I found a probably related discussion at 
[http://cygwin.com/ml/cygwin/2012-04/msg00140.html] (about one year 
ago), but it seems that there the problem was only for particular 
"-std=" choices, whereas current DJGPP fails with _any_ kind of C/C++ 
standard (including "gnu...").

Am I doing something wrong, or it is a bug?

P.S. For comparison, gcc 4.6.1 in Debian works fine.


-- 
Best regards,
Mikhail Ryazanov

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019