I compile game source code in Visual Studio and found some error while compile.
error C2440: 'initializing' : cannot convert from 'eKind' to 'LPCTSTR' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
enum eKind
{
NONE,
CONSO, //consonant
V_UP, //vowel in upper
SV_UP, //special vowel in upper
V_SIDE, //vowel in side
V_UN, //vowel in under
V_UPSI, //vowel in upper and side
SOU, //special in upper
ENG, //english and number
}
LastKind = NONE;
LPCTSTR thai[255] = {
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG,
ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, NONE, NONE, NONE, NONE, NONE,
NONE, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG,
ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, ENG, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO,
CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO,
CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO, CONSO,
V_SIDE, V_UP, V_SIDE, V_UPSI, V_UP, V_UP, V_UP, V_UP, V_UN, V_UN, NONE, NONE, NONE, NONE, NONE, NONE,
V_SIDE, V_SIDE, V_SIDE, V_SIDE, V_SIDE, V_SIDE, V_SIDE, SV_UP, SOU, SOU, SOU, SOU, SOU, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE
};
What's the problem? How to solve this?
Unlike C#, for example, you can get a string representation of an enum in C/C++. If you want to so this sort of thing you'll need to write the some yourself. For example:
An
enum
is a scalar data type.LPCTSTR
is a typedef of a pointer tochar
orwchar_t
(depends on Unicode setting).C++ does not allow the implicit conversion from a scalar to a pointer. Use an appropriate source data type to assign it to a
LPCTSTR
.In your example you want to define an array of
TCHAR
instead of a pointer to it.