【发布时间】:2019-03-10 01:28:20
【问题描述】:
我最近切换到Ubuntu 16.04。我在 Ubuntu 上使用 vscode 作为 IDE。我配置了其他语言,但我无法为C/C++ 配置。我创建了c_cpp_properties.json, launch.json & tasks.json。当我开始编译任何给定的代码时,当拟合函数如printf 或malloc 时会出错。
错误信息:
无法打开“printf.c”:找不到文件 (file:///build/glibc-Cl5G7W/glibc-2.23/stdio-common/printf.c)。
我该如何解决这个问题?
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/test.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"pointer_revision.c",
"-o",
"test.exe"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
c_cpp_properties.json
{
"configurations": {
"name": "Linux",
"includePath": [
"${workspaceFolder}",
"/usr/include/x86_64-linux-gnu/5/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu/5/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}",
"/usr/include/x86_64-linux-gnu/5/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu/5/include-fixed",
"/usr/include/x86_64-linux-gnu",
"/usr/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/usr/bin/gcc"
}
}
【问题讨论】:
-
这是一个特性,而不是一个错误。字面上地!他们说这是“设计”在这里:github.com/Microsoft/vscode-cpptools/issues/1123
-
“像 printf 或 malloc 这样的 fit 函数会报错。”,这是什么意思?
-
有一个拼写错误。不合身,会被打。
标签: c linux ubuntu visual-studio-code vscode-settings