我試圖編譯C代碼VS C++快訊2010年,但我得到了下面的錯誤跟蹤:如何編譯在Visual C C++編寫代碼表示2010
1>------ Build started: Project: test4, Configuration: Release Win32 ------
1>cl : Command line error D8045: cannot compile C file 'test4.c' with the /clr option
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
當我試着和CPP擴展我得到編譯此錯誤跟蹤:
1>------ Build started: Project: test4, Configuration: Release Win32 ------
1> test4.cpp
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(86): error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(98): error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(138): error C2664: 'OpenServiceW' : cannot convert parameter 2 from 'const char [9]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(196): error C2664: 'GetSystemDirectoryW' : cannot convert parameter 1 from 'CHAR [80]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(203): error C2664: 'lstrcatW' : cannot convert parameter 1 from 'CHAR [80]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(208): error C2664: 'CopyFile' : cannot convert parameter 1 from 'const char [13]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\rkelly1\desktop\io\test4\test4\pt_ioctl.c(236): error C2664: 'CreateServiceW' : cannot convert parameter 2 from 'const char [9]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>test4.cpp(27): error C3861: 'kbhit': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
你的錯誤與.cpp擴展編譯時說明您是混合了'wchar_t'和' char'。即使您將該文件編譯爲C文件,您也需要修復這些錯誤。 – 2011-05-19 17:17:26