News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

swprintf broken

Started by severach, October 02, 2006, 03:25:27 AM

Previous topic - Next topic

severach

_sntprintf is aliased to swprintf which causes an Access Violation in Win32. A single #define fixes it.

#define swprintf _snwprintf // remove this to make the following code crash

 CHAR b[5]; memset(b,'x',sizeof(b));
 n=snprintf(b,NELEM(b)-1,"WorksFine");
 WCHAR a[5]; memset(a,'x',sizeof(a));
 n=_snwprintf(a,NELEM(a)-1,L"WorksFine");
 n=swprintf(a,NELEM(a)-1,L"AccessViolation");


Now if only you library makers could get your maxsize handling, \0 termination, and return values all consistant.

[edit: this seems to be fixed in the released version]