在VC6中编译一直提示类型转换错误,请各位高手给看看是怎么回事,同样的代码在Windows程序设计附带的代码中就可以编译通过,我也在预处理中加入了UNICODE.
static BOOL bValidFile;
static BYTE buffer[8192];
static HWND hwndList,hwndText;
static RECT rect;
static TCHAR szFile[MAX_PATH+1];
HANDLE hFile;
HDC hdc;
int i,cxChar,cyChar;
PAINTSTRUCT ps; 143 ReadFile (hFile,buffer,MAXREAD,&i,NULL);
151 DrawTextA (hdc, buffer, i, &rect, DTFLAGS) ;
compiling...
ps96.cpp
D:\C++\ps96\ps96.cpp(143) : error C2664: 'ReadFile' : cannot convert parameter 4 from 'int *' to 'unsigned long *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\C++\ps96\ps96.cpp(151) : error C2664: 'DrawTextA' : cannot convert parameter 2 from 'unsigned char [8192]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
执行 cl.exe 时出错.ps96.exe - 1 error(s), 0 warning(s)
static BOOL bValidFile;
static BYTE buffer[8192];
static HWND hwndList,hwndText;
static RECT rect;
static TCHAR szFile[MAX_PATH+1];
HANDLE hFile;
HDC hdc;
int i,cxChar,cyChar;
PAINTSTRUCT ps; 143 ReadFile (hFile,buffer,MAXREAD,&i,NULL);
151 DrawTextA (hdc, buffer, i, &rect, DTFLAGS) ;
compiling...
ps96.cpp
D:\C++\ps96\ps96.cpp(143) : error C2664: 'ReadFile' : cannot convert parameter 4 from 'int *' to 'unsigned long *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\C++\ps96\ps96.cpp(151) : error C2664: 'DrawTextA' : cannot convert parameter 2 from 'unsigned char [8192]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
执行 cl.exe 时出错.ps96.exe - 1 error(s), 0 warning(s)
151 DrawTextA (hdc, (char*)buffer, i, &rect, DTFLAGS) ; 强制转换一下就行了。