OneLoneCoder / synth

The latest code to make your own virtual sound synthesizer in Windows. Please see the videos associated with this code. Links in the source files.
http://www.onelonecoder.com
361 stars 130 forks source link

Not compiling with Visual Studio 2019, type conversion error #6

Open jaysonpowers-zz opened 5 years ago

jaysonpowers-zz commented 5 years ago

line 182 is throwing a type conversion error

sDevices.push_back(woc.szPname);

woc.szPname is a TCHAR array and sDevices is a vector \<wstring>

I haven't found a successful conversion from the two on the internet yet

jaysonpowers-zz commented 5 years ago

I did find a rather unelegant solution:

string temp(woc.szPname); wstring temp2(temp.begin(), temp.end()); sDevices.push_back(temp2);

It's working now at least, hehe.

djm1176 commented 4 years ago

@mathacka In one solution, woc.szName was of type WCHAR, which did not need modification. In another project, it was of type CHAR (when peeking definition) and your modification was needed. Interesting

antoniomangoni commented 4 years ago

this solution is not working for me.. it still gives me that same error

vooh commented 4 years ago

change your character set to Unicode character set under Project Configuration Properties->Advanced->Character Set- Use Unicode Character Set. Don't do any code modifications. It works very well once the Unicode is set.

SNaKeRUBIN commented 4 years ago

Define using tString = std::basic_string<TCHAR>; Now simply declare std::vector<tString> devices; Note: If you are printing, you might want an overloaded function that can use std::string and std::wstring