Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

std::string in unicode builds

Status
Not open for further replies.

ranadhir

Programmer
Nov 4, 2003
54
IN
Let us take a simple function
::MessageBox(0,data.c_str(),"log",0);
where data is a std::sting type.

When i change the build type to unicode ,this will spit out error
error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'

How can i feed in the underlying data of a std::string type(const char *),so that it builds smoothly in both MBCS and UNICODe builds.
 
There's also a std::wstring type.
If that works, maybe you could do something like:
Code:
#ifdef UNICODE
   typedef String std::wstring;
#else
   typedef String std::string;
#endif //UNICODE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top