用于在 vscode 中运行多个 cpp 类的代码运行器配置 [英] Code-runner configuration for running multiple cpp classes in vscode

查看:21
本文介绍了用于在 vscode 中运行多个 cpp 类的代码运行器配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个类和标题的 cpp 项目.我试图让它编译并使用任务和午餐.json 运行,但我放弃了.我意识到不久前我在使用 Python interperter 时遇到了问题,并在使用 Python 时转到代码运行器配置以更改默认的 interperter.但是,当有多个类和头文件时,必须有一种方法使代码运行器即使在 cpp 中也能工作.这是我在配置中发现的:

I have a cpp project with multiple classes and headers. I was trying to make it compile and run using tasks and lunch.json but I gave up. I realized that a while ago I had a problem with Python interperter and went to code-runner configuration to change the default interperter when working with Python. But there has to be a way to make code-runner work even in cpp when having multiple classes and header. This is what I found in the configuration:

"code-runner.executorMap": {
    "cpp": "cd $dir && g++ -std=c++14 $fileName  -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},

我看到只有一个文件被编译.我应该在上面的代码中添加什么才能使 vscode 编译所有类?

I see that only one file gets compiled. What should I add to the code above to make vscode compile all classes?

推荐答案

我将该行更改为

"code-runner.executorMap": {
    "cpp": "cd $dir && g++ -std=c++14 *.cpp  -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},

现在它就像一个魅力.

这篇关于用于在 vscode 中运行多个 cpp 类的代码运行器配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆