How to prepare/configure development environment for C++ projects in Visual Code Editor?

前端 未结 2 1718
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 04:28

I\'m working with JavaScript projects using nodejs and visual code editor. I wonder is it possible to configure such a great code editor for C++ projects.

I want to link

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 05:27

    Use the following in the tasks.json file, changing "helloworld" strings as appropriate.

    // Available variables which can be used inside of strings.
    // ${workspaceRoot}: the root folder of the team
    // ${file}: the current opened file
    // ${fileBasename}: the current opened file's basename
    // ${fileDirname}: the current opened file's dirname
    // ${fileExtname}: the current opened file's extension
    // ${cwd}: the current working directory of the spawned process
    
    {
        "version": "0.1.0",
        "command": "gcc",
        "args": ["-Wall", "helloWorld.c", "-o", "helloWorld"],
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["relative", "${workspaceRoot}"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
    

    EDIT: This requires gcc to be available on the path. The build can be triggered with Ctrl + shift + b. Debugger is not available yet AFAIK

提交回复
热议问题