之前使用别的集成开发环境没这么接触过makefile,json等东西导致使用vscode问题频发,光是include报错就调整了半天,记录一下解决方法
1.修改c_cpp_properties.json,把当前需要文件路径包含进去,使用**可以递归包含
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/s7test/src/**"
],
2.修改tasks.json,分开包括并且前面要加I,这里不能使用**来递归包含,如果有cpp还要改成g++
"tasks": [
{
"type": "cppbuild",
"label": "build all C files",
"command": "C:\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"${fileDirname}\\*.c",
"-IC:\\Users\\Lenovo\\Desktop\\f4_testcode\\s7test\\src\\core",
"-IC:\\Users\\Lenovo\\Desktop\\f4_testcode\\s7test\\src\\lib",
"-IC:\\Users\\Lenovo\\Desktop\\f4_testcode\\s7test\\src\\sys",
"-g",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
},