[英]Error MSB6006 “CL.exe” exited with code 2 in compile in visual studio c++
I work on a c++ console project. 我在c ++控制台项目上工作。 this project has in msmpisdk platform.
该项目在msmpisdk平台中具有。 When I compiled in Visual Studio 2019 the error below occurred:
当我在Visual Studio 2019中编译时,发生以下错误:
"Severity Code Description Project File Line Suppression State...Error MSB6006 "CL.exe" exited with code 2....C:\\Program Files (x86)\\Microsoft VisualStudio\\2019\\Enterprise\\MSBuild\\Microsoft\\VC\\v160-\\Microsoft.CppCommon.targets 429."
“严重性代码描述项目文件行抑制状态...错误MSB6006” CL.exe“退出,代码为2。...C:\\ Program Files(x86)\\ Microsoft VisualStudio \\ 2019 \\ Enterprise \\ MSBuild \\ Microsoft \\ VC \\ v160 -\\ Microsoft.CppCommon.targets429。”
I checked my code, it seems OK, also check ref lib of project, it seems OK. 我检查了我的代码,看来还可以,还检查了项目的ref lib,看来还可以。
I searched the web. 我在网上搜索。
but the same error occurred and my code doesn't compile. 但发生相同的错误,我的代码无法编译。
at last I found the problem. 最后我发现了问题。
#include "iostream" class myclass1 { public: int _AMethod() { return 55; } }; int main() { myclass1* myVariable; int x = 0; if (x == 0) { myVariable = (myclass1*)malloc(sizeof(myclass1) * 5); //myVariable = init(); } if (x == 0) { myVariable->_AMethod(); } }
now when compile this error occurred: Error MSB6006 "CL.exe" exited with code 2. 现在在编译时发生此错误:错误MSB6006“ CL.exe”退出,代码2。
this error can solved easily .. with init in definition, like below : 通过定义init可以轻松解决此错误,如下所示:
#include "iostream" class myclass1 { public: int _AMethod() { return 55; } }; int main() { myclass1* myVariable=(myclass1*)malloc(sizeof(myclass1) * 5); int x = 0; if (x == 0) { //myVariable = (myclass1*)malloc(sizeof(myclass1) * 5); //myVariable = init(); } if (x == 0) { myVariable->_AMethod(); } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.