Problems with OutputDebugString

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
yukino30
Posts: 13
Joined: January 27th, 2016, 9:36 am

Problems with OutputDebugString

Post by yukino30 » August 21st, 2017, 4:05 pm

Hello,
I'm using Chili Framework 2016 in Visual Studio to test a simple project. I wanted to use OutputDebugString to show in the output some variables. But it doesn't compile.

When I try to compile the program is says:

'void OutputDebugStringW(LPCWSTR)': cannot convert argument 1 from 'const char *' to 'LPCWSTR' Engine

This is the code, nothing strange, just a simple debug.

std::stringstream ss;
ss << " Pickups "<<std::endl;
OutputDebugString(ss.str().c_str());


I'm using Visual Studio 2015 Community.

Thanks

reductor
Posts: 49
Joined: October 24th, 2016, 12:23 pm

Re: Problems with OutputDebugString

Post by reductor » August 21st, 2017, 11:21 pm

The builds are likely using unicode, you could use wstringstream instead or OutputDebugStringA (ASCII version)

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Problems with OutputDebugString

Post by chili » August 22nd, 2017, 1:17 am

Yup, the framework solution is setup to use wide character strings (16-bit chars on Windows). If you want to use wide strings, use wstring instead of string, and ditto for wstringstream, to_wstring, etc.

Your string literals should also be L" Pickups " (prefix with L to denote a wide char string literal).
Chili

yukino30
Posts: 13
Joined: January 27th, 2016, 9:36 am

Re: Problems with OutputDebugString

Post by yukino30 » August 22nd, 2017, 9:35 am

Yup!
That worked thanks!! Problem solved

Post Reply