创建在Visual Studio代码中构建CPP和C文件的任务
我在task.json
文件中的任务中有构建项目的文件:
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: build",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceFolder}/*.cpp",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/g++"
},
从abound.json
调用任务。 line 是否“ $ {workspacefolder}/*。cpp”
表示任务仅构建cpp
文件?如果项目同时具有 - cpp
和c
文件,该如何处理?
I have task in my task.json
file in Visual Studio Code that builds project :
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: build",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceFolder}/*.cpp",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/g++"
},
Task is called from launch.json
. Does line "${workspaceFolder}/*.cpp"
means that task builds only cpp
files? How to deal if project has both - cpp
and c
files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
G ++可以编译任何.c或.cpp文件,但仅将其视为C ++文件。
GCC可以编译任何.C或.CPP文件,但分别将其视为C ++。
您可以尝试使用GCC。
否则,如果您有一个主
。
也许这可能会带来更多澄清: https:// code。 VisualStudio.com/docs/cpp/c-cpp-properties-schema-reference
G++ can compile any .c or .cpp files but they will be treated as C++ files only.
GCC can compile any .c or .cpp files but they will be treated as C and C++ respectively.
You could try using GCC.
Else if you have a main.cpp the uses
compiling only the main file should work.
Perhaps this might bring some more clarification : https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference