文章目录
- 【vscode】FILE提示报错及未有FILE代码提示问题
- 一、说明
- 二、前言
- 三、错误提示
- 四、解决方案
- 1、c_cpp_properties.json
- 2、修改 c_cpp_properties.json
- 3、修改结果
- 五、更新2019年4月5日下午15:17
- 六、更新2019年4月5日晚 23:20
【vscode】FILE提示报错及未有FILE代码提示问题
一、说明
1、windows系统
2、MinGW
二、前言
FILE)这个相关的代码没有提示,对于强迫症患者来说就特别的烦恼。
三、错误提示
报错如下图所示,虽然可以不用在意这个,代码编写完之后可以在后台直接运行不影响结果,但是这里始终是不美观!
四、解决方案
1、c_cpp_properties.json
如下所示:是我的配置结果
2、修改 c_cpp_properties.json
通过命令行查看自己的配置路径:gcc -v -E -x c++ -
所以说明我的配置路径就有问题
修改如下所示:
3、修改结果
且再次输入:FILE时就会有提示奥。。。。。。
五、更新2019年4月5日下午15:17
1、更新一下c_cpp_properties.json配置文件
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:\\yan\\MinGW\\include\\",
"D:\\yan\\MinGW\\include\\gdb\\",
"D:\\yan\\MinGW\\include\\libiberty\\",
"D:/yan/MinGW/lib/",
"D:\\yan\\MinGW\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\32/",
"D:/yan/MinGW/lib/gcc/x86_64-w64-mingw32/8.1.0/include/*",
"D:/yan/MinGW/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/*",
"ED:/yan/MinGW/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ssp/*"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64",
"compilerPath":"D:/yan/MinGW\bin/gcc.exe",
"browse": {
"path": [
"${workspaceRoot}",
"${MINGW_HOME}\\include\\c++\\8.1.0",
"${MINGW_HOME}\\include\\c++\\8.1.0\\x86_64-w64-mingw32",
"${MINGW_HOME}\\include\\c++\\8.1.0\\backward",
"${MINGW_HOME}\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include",
"${MINGW_HOME}\\include",
"${MINGW_HOME}\\x86_64-w64-mingw32\\include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
六、更新2019年4月5日晚 23:20
1、c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64",
"compilerPath":"D:/yan/MinGW/bin/gcc.exe",
"browse": {
"path": [
"${workspaceRoot}",
"${MINGW_HOME}\\include\\c++\\8.1.0",
"${MINGW_HOME}\\include\\c++\\8.1.0\\x86_64-w64-mingw32",
"${MINGW_HOME}\\include\\c++\\8.1.0\\backward",
"${MINGW_HOME}\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include",
"${MINGW_HOME}\\include",
"${MINGW_HOME}\\x86_64-w64-mingw32\\include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
2、launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg", // 配置类型,这里只能为cppdbg
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
//"program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",// 将要进行调试的程序的路径
"program": "${fileDirname}/${fileBasenameNoExtension}.exe", // 将要进行调试的程序的路径
"args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可
"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${workspaceRoot}", // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
"environment": [],
"externalConsole": true, // 调试时是否显示控制台窗口,一般设置为true显示控制台
"MIMode": "gdb",
"miDebuggerPath": "D:/yan/MinGW/bin/gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应
"preLaunchTask": "g++", // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3、settings.json
{
"files.encoding": "gbk",
"window.zoomLevel": 0,
"[cpp]":{
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
},
"[c]":{
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
},
"workbench.colorTheme":"Visual Studio Dark", // 设置界面Visual Studio Light
"extensions.ignoreRecommendations": true,
}
4、tasks.json
{
"version": "2.0.0",
"command": "g++",
"args": ["-g","${file}","-o","${fileBasenameNoExtension}.exe"], // 编译命令参数
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}