2013-05-21 2 views
0

내가 BUTT (http://butt.sourceforge.net/)를 컴파일하기 위해 노력하고있어에서 '{일명 * wchar_t를} LPWSTR'에 '숯불 *을'변환 할 수 없습니다. 나는 유형 error: cannot convert 'char*' to 'LPCWSTR {aka const wchar_t*}'의 오류가 가장 많이 발생하는 것 같습니다. 내가 누락 한 유니 코드를 사용하기위한 간단한 옵션이 있습니까? 내 붙여 넣기 상단에서 g ++에 전달되는 옵션을 볼 수 있습니다. 여기 컴파일 엉덩이 MingwW64와 창에 할당

[email protected]_0-PC /z/src/butt-0.1.12 
$ make 
make -C src 
check for ../config.mk ... 
ok. 
make[1]: Entering directory `/z/src/butt-0.1.12/src' 
g++ -I/usr/local/include -I/usr/local/include -I/usr/local/include -I. -I/usr/ 
local/include -Wall -O2 -DVERSION=\"butt-0.1.12\" `` -IFLTK -I/usr/local/includ 
e -I/usr/local/include/FL/images -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_S 
OURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DFLTK1 -DHAVE_FLTK -ILIBVORB 
IS -DHAVE_LIBVORBIS -ILIBLAME -DHAVE_LIBLAME -c -o FLTK/Fl_Native_File_Cho 
oser.o FLTK/Fl_Native_File_Chooser.cpp 
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx: In member function 'void Fl_Native_File_C 
hooser::ClearOFN()': 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:244:24: error: cannot convert 'char*' to ' 
LPWSTR {aka wchar_t*}' in assignment 
     _ofn.lpstrFile = strfree((char*)_ofn.lpstrFile); 
         ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:247:30: error: cannot convert 'LPCSTR {aka 
const char*}' to 'LPCWSTR {aka const wchar_t*}' in assignment 
     _ofn.lpstrInitialDir = (LPCSTR)strfree((char*)_ofn.lpstrInitialDir); 
          ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx: In member function 'int Fl_Native_File_Ch 
ooser::showfile()': 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:312:23: error: cannot convert 'char*' to ' 
LPWSTR {aka wchar_t*}' in assignment 
    _ofn.lpstrFile = new char[fsize]; 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:319:21: error: cannot convert 'char*' to ' 
LPCWSTR {aka const wchar_t*}' in assignment 
    _ofn.lpstrTitle = _title ? _title : NULL; 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:321:22: error: cannot convert 'char*' to ' 
LPCWSTR {aka const wchar_t*}' in assignment 
    _ofn.lpstrFilter = _parsedfilt ? _parsedfilt : NULL; 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:333:53: error: cannot convert 'LPWSTR {aka 
wchar_t*}' to 'char*' for argument '1' to 'char* strncpy(char*, const char*, si 
ze_t)' 
    strncpy(_ofn.lpstrFile, _preset_file, _ofn.nMaxFile); 
                ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:334:25: error: no matching function for ca 
ll to 'Fl_Native_File_Chooser::Unix2Win(WCHAR*&)' 
    Unix2Win(_ofn.lpstrFile); 
         ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:334:25: note: candidate is: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: void Fl_Native_File_Chooser:: 
Unix2Win(char*) 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:272:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::Unix2Win(char *s) { 
    ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: no known conversion for arg 
ument 1 from 'LPWSTR {aka wchar_t*}' to 'char*' 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:272:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::Unix2Win(char *s) { 
    ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:343:23: error: cannot convert 'char*' to ' 
LPCWSTR {aka const wchar_t*}' in assignment 
    _ofn.lpstrInitialDir = strnew(_directory); 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:352:41: error: cannot convert 'char*' to ' 
LPWSTR {aka wchar_t*}' for argument '2' to 'DWORD GetCurrentDirectoryW(DWORD, LP 
WSTR)' 
    GetCurrentDirectory(MAX_PATH, oldcwd); 
             ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:372:45: error: cannot convert 'char*' to ' 
LPCWSTR {aka const wchar_t*}' for argument '1' to 'WINBOOL SetCurrentDirectoryW(
LPCWSTR)' 
    if (oldcwd[0]) SetCurrentDirectory(oldcwd); 
              ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:377:35: error: cannot convert 'char*' to ' 
LPCWSTR {aka const wchar_t*}' for argument '1' to 'WINBOOL SetCurrentDirectoryW(
LPCWSTR)' 
     SetCurrentDirectory(oldcwd); 
           ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:383:40: error: no matching function for ca 
ll to 'Fl_Native_File_Chooser::set_single_pathname(WCHAR*&)' 
     set_single_pathname(_ofn.lpstrFile); 
             ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:383:40: note: candidate is: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: void Fl_Native_File_Chooser:: 
set_single_pathname(const char*) 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:208:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::set_single_pathname(const char *s) { 
    ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: no known conversion for arg 
ument 1 from 'LPWSTR {aka wchar_t*}' to 'const char*' 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:208:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::set_single_pathname(const char *s) { 
    ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:388:33: error: cannot convert 'LPWSTR {aka 
wchar_t*}' to 'const char*' in initialization 
     const char *dirname = _ofn.lpstrFile; 
           ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:395:51: error: cannot convert 'LPWSTR {aka 
wchar_t*}' to 'const char*' in initialization 
    for (const char *s = _ofn.lpstrFile + dirlen + 1; 
               ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx: In member function 'int Fl_Native_File_Ch 
ooser::showdir()': 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:460:21: error: cannot convert 'char*' to ' 
LPCWSTR {aka const wchar_t*}' in assignment 
    _binf.lpszTitle = _title ? _title : NULL; 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:483:26: error: cannot convert 'char [260]' 
to 'LPWSTR {aka wchar_t*}' in assignment 
    _binf.pszDisplayName = displayname; 
         ^
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:504:22: error: no matching function for ca 
ll to 'Fl_Native_File_Chooser::Win2Unix(TCHAR [260])' 
     Win2Unix(path); 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:504:22: note: candidate is: 
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: void Fl_Native_File_Chooser:: 
Win2Unix(char*) 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:266:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::Win2Unix(char *s) { 
    ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: no known conversion for arg 
ument 1 from 'TCHAR [260] {aka wchar_t [260]}' to 'char*' 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:266:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::Win2Unix(char *s) { 
    ^
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:505:19: error: no matching function for ca 
ll to 'Fl_Native_File_Chooser::add_pathname(TCHAR [260])' 
    add_pathname(path); 
       ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:505:19: note: candidate is: 
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: void Fl_Native_File_Chooser:: 
add_pathname(const char*) 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:216:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::add_pathname(const char *s) { 
    ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:42:20: note: no known conversion for arg 
ument 1 from 'TCHAR [260] {aka wchar_t [260]}' to 'const char*' 
#define FNFC_CLASS Fl_Native_File_Chooser 
        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:216:6: note: in expansion of macro 'FNFC_C 
LASS' 
void FNFC_CLASS::add_pathname(const char *s) { 
    ^
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:508:22: error: cannot convert 'TCHAR* {aka 
wchar_t*}' to 'const char*' for argument '1' to 'size_t strlen(const char*)' 
    if (!strlen(path)) return(1);    // don't return empty pathnames 

        ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx: In member function 'void Fl_Native_File_C 
hooser::add_filter(const char*, const char*)': 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:617:56: warning: field precision specifier 
'.*' expects argument of type 'int', but argument 3 has type 'long long unsigne 
d int' [-Wformat=] 
    sprintf(name, "%.*s Files", sizeof(name)-10, winfilter); 
                 ^
FLTK/Fl_Native_File_Chooser_WIN32.cxx:619:55: warning: field precision specifier 
'.*' expects argument of type 'int', but argument 3 has type 'long long unsigne 
d int' [-Wformat=] 
     sprintf(name, "%.*s", sizeof(name)-10, name_in); 
                ^
In file included from FLTK/Fl_Native_File_Chooser_WIN32.cxx:35:0, 
       from FLTK/Fl_Native_File_Chooser.cpp:26: 
FLTK/Fl_Native_File_Chooser_common.cxx: At global scope: 
FLTK/Fl_Native_File_Chooser_common.cxx:60:14: warning: 'char* strapp(char*, cons 
t char*)' defined but not used [-Wunused-function] 
static char *strapp(char *s, const char *val) { 
      ^
In file included from FLTK/Fl_Native_File_Chooser.cpp:26:0: 
FLTK/Fl_Native_File_Chooser_WIN32.cxx:61:13: warning: 'void dnullprint(char*)' d 
efined but not used [-Wunused-function] 
static void dnullprint(char *wp) { 
      ^
<builtin>: recipe for target `FLTK/Fl_Native_File_Chooser.o' failed 
make[1]: *** [FLTK/Fl_Native_File_Chooser.o] Error 1 
make[1]: Leaving directory `/z/src/butt-0.1.12/src' 
Makefile:48: recipe for target `butt' failed 
make: *** [butt] Error 2 

은 몇 가지 오류를 포함하는 첫 번째 함수입니다 :

// CLEAR MICROSOFT OFN (OPEN FILE NAME) CLASS 
void FNFC_CLASS::ClearOFN() { 
    // Free any previously allocated lpstrFile before zeroing out _ofn 
    if (_ofn.lpstrFile) { 
     _ofn.lpstrFile = strfree((char*)_ofn.lpstrFile); 
    } 
    if (_ofn.lpstrInitialDir) { 
     _ofn.lpstrInitialDir = (LPCSTR)strfree((char*)_ofn.lpstrInitialDir); 
    } 
    _ofn.lpstrFilter = NULL;  // (deleted elsewhere) 
    int temp = _ofn.nFilterIndex; // keep the filter_value 
    memset((void*)&_ofn, 0, sizeof(_ofn)); 
    _ofn.lStructSize = sizeof(OPENFILENAME); 
    _ofn.nFilterIndex = temp; 
} 
         ^
+0

이러한 오류 메시지는 매우 도움이되지 않습니다. –

답변

1

기회는 BUTT 유니 코드 용으로 설계된 것이 아니라, 그들이 사용 있도록 TCHAR - 인식이다는 Win32 API 함수를 호출되어있다 컴파일하는 동안 UNICODE/_UNICODE이 정의되면 유니 코드를 사용하고 그렇지 않으면 ANSI를 사용하십시오. 따라서 프로젝트 설정에 들어가서 유니 코드를 끄고 API 함수가 ANSI를 대신 사용하도록하거나 BUTT 코드를 TCHAR으로 업데이트하면됩니다. 적절할 경우 char*wchar_t* 사이에서 변환 할 수 있습니다. 당신이 그들을 일으키는 코드를 표시하지 않는 경우

+0

오케이, 나는 어쩌면 다른 방향 일 거라고 생각했다. 버트는 어디서나 정의 된 유니 코드를 가지고 있지 않습니다. – freedrull

+0

예, 프로젝트에 'UNICODE'가 정의되어 있습니다. '_ofn'은 문자열 멤버가'TCHAR'을 사용하는'OPENFILENAME' 구조체이며,'UNICODE'가 정의 될 때'wchar_t'입니다. BUTT의 코드가'char *'에 하드 코드 된 타입 캐스트를하고 있다는 사실은'OPENFILENAME'이'TCHAR'을 사용한다는 것을 알며 그것이 없어야한다는 사실을 무시하고 있습니다. 특히 –

+0

는 strfree'에 대한 호출은()''TCHAR' 인식, 새로운 숯불 []''새로운 TCHAR []''를 strncpy로 대체해야'에 대한 호출 (무언가로 대체해야)'대신'lstrcpy() '등이 사용됩니다. –