MS Visual C++ "The number of source files and corresponding outputs must match"

MS Visual c++ "The number of source files and corresponding outputs must match"

我正在尝试在 msVisual2019 中用 C++ 编译我的代码,但每次尝试都会出错:

Severity Code Description Project File Line Suppression State Error MSB6001 Invalid command line switch for "CL.exe". System.ArgumentException: The number of source files and corresponding outputs must match. at Microsoft.Build.Shared.ErrorUtilities.ThrowArgument(Exception innerException, String resourceName, Object[] args) at Microsoft.Build.Utilities.CanonicalTrackedOutputFiles.RemoveDependenciesFromEntryIfMissing(ITaskItem[] source, ITaskItem[] correspondingOutputs) at Microsoft.Build.CPPTasks.CL.PostExecuteTool(Int32 exitCode) at Microsoft.Build.CPPTasks.TrackedVCToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) at Microsoft.Build.Utilities.ToolTask.Execute() HelloWorld C:\Program Files (x86)\Microsoft Visual Studio19\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets 687

这首先发生在我(不小心)在“源文件”(附有 img)中创建了一个头文件,编译它,然后意识到我的错误并将其放回“头文件”中。现在每次我构建它,即使在我做出每一次改变之后...... 我无法让这个错误消失并且还没有找到类似问题的解决方案。 任何帮助将不胜感激,谢谢。

[mistake, build after][1]
[correction, build after][2]
[errors displayed][3]
  [1]: https://i.stack.imgur.com/SDAzP.png
  [2]: https://i.stack.imgur.com/PG54S.png
  [3]: https://i.stack.imgur.com/ZhEsH.png

根据其描述,对文件进行预处理似乎不是一个好主意:此选项会抑制编译...很高兴您将其设置为否。– rturrado 7 月 10 日 21:04 谢谢@rturrado :D