1.跨平台開發之~ VSCode開發第一個C程序


VSCode的安裝就不講了,可以參考這個(http://www.cnblogs.com/dunitian/p/6661644.html

寫一個簡單的C,然后F5運行,根據提示來配置文件

刪掉前面的內容

運行發現還是不行,Ctrl+Shift+B,輸入Task

選擇Others

把command和args配置一下,${file}代表當前打開文件

Ctrl+Shift+B生成一下

F5運行調試

官方文檔:https://code.visualstudio.com/docs/languages/cpp

參考:

https://code.visualstudio.com/docs/editor/tasks

https://code.visualstudio.com/docs/editor/debugging

 

附錄:

2018.3.19更新

Ctrl+Shift+B編譯下,添加tasks文件

tasks.json 最新配置:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "c++",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

F5運行一下,添加launch文件

launch.json最新配置

{
    // 使用 IntelliSense 了解相關屬性。 
    // 懸停以查看現有屬性的描述。
    // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM