c++ - 是什么导致 MS Visual Studio 无法识别构建错误?

标签 c++ visual-studio-2010 visual-studio visual-studio-2012

Visual Studio Express 2010 中,我通常只能构建一个程序一次,然后要进行任何更改,我必须将我的代码粘贴到一个新项目中。它会说构建成功,但随后我尝试运行它并收到一条错误消息:

"This project is out of date-- would you like to build it?"

然后我单击是,我收到另一条错误消息,指出存在构建错误,我必须从上次成功的构建继续。 有时 我没有运行上次成功的构建,而是收到一条错误消息,说,

"Unable to open [directory to program]. The system cannot find the file specified."

出于这个原因,我通常使用 Visual Express 2012,但即便如此,它时不时地发生,似乎是随机的。一旦问题开始出现,就没有明显的方法来修复它(重建和重新启动 Visual Studio 都会产生相同的结果)。在 Visual Studio Pro 2012 中,这似乎也发生了。

编辑:这是在我前面的输出框中(2010 版)

1>------ Build started: Project: Lab01, Configuration: Debug Win32 ------
1>  Lab01.cpp
1>c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\system.core.dll : warning C4945: 'ExtensionAttribute' : cannot import symbol from 'c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\system.core.dll': as 'System::Runtime::CompilerServices::ExtensionAttribute' has already been imported from another assembly 'mscorlib'
1>          c:\windows\microsoft.net\framework\v4.0.30319\mscorlib.dll : see declaration of 'System::Runtime::CompilerServices::ExtensionAttribute'
1>          first seen type is used; re-order imported assemblies to use the current type
1>          This diagnostic occurred while importing type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>Lab01.cpp(28): error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem &)' : cannot convert parameter 1 from 'char [101]' to 'char &'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我猜它说那里有错误,但出于某种原因它告诉我“构建成功”...

最佳答案

查找和分析 Visual Studio 报告的错误的方法如下:

从上次成功的构建继续 - 点击NO(几乎总是)。错误应该显示在 View->Error List 中。混淆时,总是在构建后检查 View->Output 窗口,它有很多相同的信息,但更详细。

rebuilding ...same result - 完全重建应该会给出除project is outdate 之外的一些其他错误。

Lab01.cpp(28):错误 C2664: - Lab01.cpp 的第 28 行和第 3 行上下会有所帮助。

看起来你在用 std::streams 做一些不正确的事情,但我不知道在没有看到代码的情况下是什么。 这应该在错误列表中

警告 C4945: - 发生这种情况是因为您在单个项目中混合使用 .net 4.0 和 4.5 以及(可能)混合使用 clr 和非 clr 代码。从已在各处选择了正确的 .Net 库版本的新 CLR 项目重新创建可能会删除此警告。 (ExtensionAttribute 在 4.0 到 4.5 升级期间移动了)

这只是一个警告,所以应该无关紧要。

关于c++ - 是什么导致 MS Visual Studio 无法识别构建错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21023021/

相关文章:

c++ - 如何实现 split 函数来分割一行中的单词?

c++ - 为什么当构造函数引用字符串时无法正确打印?

c# - VSIX:获取 DTE 对象

c++ - std::bind 类内部的静态成员函数

c++ - 更改字体颜色时发生 SFML 访问冲突

c# - Windows XP下Visual Studio 2013远程调试过程

c++ - 关于静态函数不使用原型(prototype)的意见

c++ - 从 C++ 中查找 python 函数参数

c# - VS2010 (C#) Environment.SpecialFolder.ProgramFiles 在解决方案项目中的什么位置?

android - Xamarin Forms 使用 Shell 菜单将选项卡栏更改为工具栏