Hi
I downloaded the latest release and tried to build in Windows using the supplied Visual Studio projects.
I get these errors
-
i:2dx\cocos2dx\platform\win32\ccimage.cpp(66): error C2664: ‘RemoveFontResourceA’ : cannot convert parameter 1 from ’wchar_t ‘to ’LPCSTR’ Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
code is
<pre>
wchar_t pwszBuffer = utf8ToUtf16(m_curFontPath);
if (pwszBuffer)
{
RemoveFontResource(pwszBuffer);
RemoveFontResource accepts a LPCSTR that is const char\*
m_curFontPath is a STL string
std::string m_curFontPath;
Not sure why the trouble to convert the std::string to a wchar_t * to be passed to a function that accepts a const char**;
std::string has a member .c_str that returns exactly what is needed here
so, the code
<pre>
wchar_t** pwszBuffer = utf8ToUtf16(m_curFontPath);
if (pwszBuffer)
{
RemoveFontResource(pwszBuffer);
SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
delete [] pwszBuffer;
pwszBuffer = NULL;
}
can be just simply replaced with
RemoveFontResource(m_curFontPath.c_str());
-
i:2dx\cocos2dx\platform\win32\ccapplication.cpp(173): error C2664: ‘RegSetValueExA’ : cannot convert parameter 2 from ’const WCHAR ‘to ’LPCSTR’
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
code is
<pre>
const WCHAR wszValue = L“hide_gui”;
RegSetValueEx(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize);
The function to call should be the Unicode version
RegSetValueExW(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize);
-
i:2dx\cocos2dx\platform\win32\cceglview.cpp(165): error C2440: ‘=’ : cannot convert from ’const WCHAR **‘to ’LPCSTR’
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
code is
<pre>
static const WCHAR** kWindowClassName = L“Cocos2dxWin32”;
WNDCLASS wc; // Windows Class Structure
wc.lpszClassName = kWindowClassName; // Set The Class Name
here, this should be
static LPCSTR kWindowClassName = "Cocos2dxWin32";
because wc.lpszClassName is a LPCSTR
-
i:2dx\cocos2dx\platform\win32\cceglview.cpp(192): error C2664: ‘CreateWindowExA’ : cannot convert parameter 3 from ‘WCHAR [50]’ to ‘LPCSTR’ Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
code is
char m_szViewName[50];
WCHAR wszBuf[50] = {0};
MultiByteToWideChar(CP_UTF8, 0, m_szViewName, -1, wszBuf, sizeof(wszBuf));
m_hWnd = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
kWindowClassName, // Class Name
wszBuf, // Window Title
again, no need to convert to a WCHAR just to get a compiling error
this should be simply
m_hWnd = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
kWindowClassName, // Class Name
m_szViewName, // Window Title