【发布时间】:2020-09-29 00:10:57
【问题描述】:
我无法通过代码运行程序扩展在 VS Code 上运行我的 CPP 文件。 它发生在我尝试在 vs 代码上激活 conda 作为 python 解释器之后。
这是运行 C++ 文件后显示的错误(它在运行其他 cpp 文件时也显示相同的错误)
PS C:\Users\hp> g++ *.cpp -o job_queue && ./job_queue.exe
在行:1 字符:24
+ g++ *.cpp -o job_queue && ./job_queue.exe + ~~
标记“&&”在此版本中不是有效的语句分隔符。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine
settings.json
{
"C_Cpp.updateChannel": "Insiders",
"python.pythonPath": "C:\\Users\\hp\\AppData\\Local\\Programs\\Python\\Python38\\python.exe",
"window.zoomLevel": 0,
"timeline.pageSize": 1,
"terminal.integrated.shell.windows": "",
"code-runner.runInTerminal": true,
"code-runner.executorMap": {
"cpp": "g++ *.cpp -o $fileNameWithoutExt && ./$fileNameWithoutExt.exe",
},
"code-runner.ignoreSelection": true,
"code-runner.languageIdToFileExtensionMap": {
},
"code-runner.defaultLanguage": "C++",
"terminal.integrated.automationShell.windows": "",
}
【问题讨论】:
-
很多人都遇到了这个问题。您对使用 Visual Studio Code 的热情程度如何?让它工作需要的不仅仅是一点点挑剔的配置,如果你已经在尝试学习 C++,为什么还要同时学习与 IDE 争吵呢?看看您是否可以找到一体化的预配置 IDE,例如 Visual Studio 的免费社区版本。
-
看起来在code runner's github 上有一个关于此的问题。简单的解决方法似乎是使用
"terminal.integrated.shell.windows": "powershell.exe" -
Visual Studio Code 根本不是 IDE。经过一些修补后,您可以像使用它一样使用它,但它并不是为了“一键调试”任何东西。
-
VS Code 在 Windows 上的吸引力是什么?我看到很多初学者都在使用它,对于初学者来说它似乎有点太复杂了。 Visual Studio 似乎是更好的选择。
标签: c++ visual-studio-code vscode-settings