2017-08-09 190 views
0

我有一個現有的代碼庫與生成文件構建,我想使用Visual Studio代碼來運行它。 有我的launch.json和tasks.json。vs代碼來運行c代碼

{ 
"version": "0.2.0", 
"configurations": [{ 
    "name": "C Launch (GDB)", 
    "type": "cppdbg", 
    "request": "launch", 
    "launchOptionType": "Local", 
    "targetArchitecture": "x64",   
    "cwd": "${workspaceRoot}", 
    "program": "E:/code/c", 
    "miDebuggerPath": "E:/Program Files/TDM-GCC-64/bin/gdb64.exe", 
    "args": [""], 
    "stopAtEntry": false, 
    "externalConsole": true, 
    "preLaunchTask": "gcc"   
}] 
} 


{ 
"version": "0.1.0", 
"command": "gcc", 
"args": ["${file}", "-o", "${fileBasenameNoExtension}.exe", "-g3", "-Og", "-Wall", "-static-libgcc", "-std=c11", "-fexec-charset=GBK", "-finput-charset=UTF-8"], 
"showOutput": "always", 
"problemMatcher": { 
    "owner": "c", 
    "fileLocation": ["relative", "${workspaceRoot}"], 
    "pattern": { 
     "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", 
     "file": 1, 
     "line": 2, 
     "column": 3, 
     "severity": 4, 
     "message": 5 
    } 
} 
} 

然後當我運行Hello world,屆時將有一些問題。

enter image description here

回答

1

試着改變你的路徑在Windows上使用\而不是/。既然你有逃避JSON字符串\,實際值應爲:

"program": "E:\\code\\c\\${fileBasenameNoExtension}.exe" 

提供的內置可執行文件實際上是在E:\code\c

+0

我得到了它。但是這個問題似乎仍然exist.'launch:程序'E:\ code \ c'不存在' – Maxis

+0

如果你在磁盤上看,那裏有一個可執行文件嗎?如果您添加'.exe'以使其值爲:'「E:\\ code \\ c.exe」'? –

+0

'E:\\ code \\ c \\ $ {fileBasenameNoExtension} .exe' – Maxis