Hello,

Le 2012-07-04 17:46, niXman a écrit :
> The following code gives the right result when compiled without

Which right result exactly ?
My reading of MSDN suggests a negative return value.

> defined __USE_MINGW_ANSI_STDIO macro.
> But, if __USE_MINGW_ANSI_STDIO macro is defined - the result is 6.
> Why?

http://pubs.opengroup.org/onlinepubs/009695399/functions/snprintf.html

Upon successful completion, the snprintf() function shall return the
number of bytes that would be written to s had n been sufficiently large
excluding the terminating null byte.

So it seems return value of 6 corresponds to posix expectation.

> 
> code:
> #include <stdio.h>
> int main() {
>     wchar_t buf[2];
>     int len = snwprintf(buf, sizeof(buf) / 2, L"world!");
>     printf("%d\n", len);
> }
> 
> 
> Thanks.
> 
> 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to