I'm using vswprintf to form a wchar_t* str from a formatted string. In that formatted string, to print a std:string, Mac accepts as %s while Windows VS2008 accepts as %S. Example
void widePrint(const wchar_t* fmt, ...) {
va_list args;
va_start(args, fmt);
wchar_t buf[32*1024] = {0};
vswprintf(buf,(32*1024 - 1),fmt, args);
...//Prints buf
...
}
...
std::string str = "normal String";
std::wstring strW = L"wideStr";
widePrint(L"str: %S wStr: %ls",str.c_str(), strW.c_str()); //Windows - VS2008
widePrint(L"str: %s wStr: %ls",str.c_str(), strW.c_str()); //Mac - XCode 3.2.6
Why is this difference in behavior? Is there any way to print std::string/char* in vswprintf in platform independent form?