从VC6.0 到EVC报错.请高手指点
-------------------Configuration: MySqurt - Win32 (WCE emulator) Debug--------------------
Compiling...
MySqurt.cpp
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(104) : error C2664: 'CreateThread ' : cannot convert parameter 3 from 'int (void *) ' to 'unsigned long (__cdecl *)(void *) '
None of the functions with this name in scope match the target type
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(266) : error C2664: 'CreateThread ' : cannot convert parameter 3 from 'int (void *) ' to 'unsigned long (__cdecl *)(void *) '
None of the functions with this name in scope match the target type
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(287) : error C2664: 'recv ' : cannot convert parameter 2 from 'unsigned char * ' to 'char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(295) : error C2664: 'recv ' : cannot convert parameter 2 from 'unsigned char * ' to 'char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(313) : error C2440: '= ' : cannot convert from 'void * ' to 'unsigned char * '
Conversion from 'void* ' to pointer to non- 'void ' requires an explicit cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(315) : 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
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(324) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(329) : error C2664: 'recv ' : cannot convert parameter 2 from 'unsigned char * ' to 'char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(336) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(346) : error C2664: 'recv ' : cannot convert parameter 2 from 'unsigned char * ' to 'char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(350) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(420) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(423) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(425) : error C2440: '= ' : cannot convert from 'void * ' to 'unsigned char * '
Conversion from 'void* ' to pointer to non- 'void ' requires an explicit cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(427) : error C2664: 'recv ' : cannot convert parameter 2 from 'unsigned char * ' to 'char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(462) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(470) : error C2664: 'recv ' : cannot convert parameter 2 from 'unsigned char * ' to 'char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(481) : error C2664: 'WriteFile ' : 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
E:\WORKING\WIN CE\MySqurt\MySqurt.cpp(487) : error C2664: 'send ' : cannot convert parameter 2 from 'unsigned char * ' to 'const char * '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
MySqurt.exe - 19 error(s), 0 warning(s)
[解决办法]
有两类问题,
1.因为VC6.0默认的编译选项是MBCS,所以你的程序是在非UNICODE环境下编译的。而EVC要求必须使用UNICODE环境,所有字符串都要使用TCHAR或者WCHAR,如果你的字符串是CHAR的,带入EVC中的UNICODE 版本的API,就会出错
2.另一类错误是一些API的定义与VC有点差异,有的你强制转换一下就好。
你可以这样调试,想把VC6程序改成UNICODE版本(去掉MBCS,加上_UNICODE,UNICODE),如果编译通过了再移植。