0

struct StaticString
{
 StaticString() { Str = NULL; }
 ~StaticString() { if(Str) delete [] Str; Str=0; }

 char* Str;

 void operator = (const char * pchar)
 {
  Str = new char[strlen(pchar)+1];
  strcpy(Str,pchar);
 }
 operator LPCTSTR() const
 {
  return Str;
 }
 operator PCHAR() const
 {
  return Str;
 }
 
};

error C2440: 'return' : cannot convert from 'char *const ' to 'LPCTSTR'

Its from game . and how can i fix that? i search in google but no one work

Rakha
  • 3
  • 1

1 Answers1

0

LPCTSTR is "long pointer to constant TCHAR string".

The TCHAR type is ancient. It dates back to the original transition from "ANSI" to "wide-character" Unicode with Windows 98/NT.

#ifdef _UNICODE
typedef wchar_t TCHAR;
#else
typedef char TCHAR;
#endif

Most projects these days default to _UNICODE which means TCHAR is not a char but is instead wchar_t.

See What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?

Generally you should avoid using these Windows portable types and stick with C++ standard types.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81