自己在配置VS Code Arduino開發環境中遇到的問題,類似這種,錯誤顯示未定義標識符。關於VS Code配置Arduino開發環境 網上有需多,我就不在敘述了,我只是記錄我自己遇到的問題。
主要問題是頭文件索引丟失,intellisense不能自動找到需要的頭文件路徑。需要在用戶設置中強制intellisense使用Tag Parser,遞歸方式檢索頭文件。
添加方式方式如下:
首先
其次在輸入框輸入Arduino,檢索。
打開settings.json 配置相關文件:
添加如下所示的2行代碼。
自己的配置代碼如下:
其中 “arduino.path”: “D:\Arduino”,是自己安裝Arduino的路徑。
{
// 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": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:/MinGW/mingw64/bin",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Build"
}
],
"window.zoomLevel": 0,
"terminal.integrated.inheritEnv": false,
"task.autoDetect": "off",
"kite.showWelcomeNotificationOnStartup": false,
"arduino.path": "D:\\Arduino", //這個是安裝路徑,可能不一樣
"C_Cpp.updateChannel": "Insiders",
"C_Cpp.intelliSenseEngineFallback": "Disabled", //需要添加的
"C_Cpp.intelliSenseEngine": "Tag Parder", // 需要添加的
"arduino.additionalUrls": "",
"workbench.colorTheme": "Monokai"
}
保存之後,發現未定義標識錯誤消失了。