gpt4 book ai didi

c - 如何在 Visual C++ Express 2010 中编译 C 代码

转载 作者:太空狗 更新时间:2023-10-29 15:18:31 26 4
gpt4 key购买 nike

我正在尝试在 VS C++ Express 2010 中编译 C 代码,但我得到以下错误跟踪:

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 ==========

最佳答案

/clr 表示使用 .Net 运行时 - 而不是 c 语言运行时!

只要调用文件 .c 就可以了,有一个标志可以阻止你使用任何 c++ 特性。

转到属性 -> c/c++ -> 高级 -> 编译为并选择“c”

关于c - 如何在 Visual C++ Express 2010 中编译 C 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6062101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com