NO

Author Topic: swprintf broken  (Read 2384 times)

severach

  • Guest
swprintf broken
« on: October 02, 2006, 03:25:27 AM »
_sntprintf is aliased to swprintf which causes an Access Violation in Win32. A single #define fixes it.

Code: [Select]
#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]