c++ - 在 VS Code 中使用 Arduino 时,IntelliSense 会引发 #include 错误
问题描述
我想在 VS Code 中开发 Arduino 代码。因此,我安装了 Arduino IDE 和 Arduino 扩展 vor VS Code。
在 VS Code 中打开 Arduino 项目后,扩展c_cpp_properties.json
为 IntelliSense 创建了以下文件(摘录):
"includePath": [
"/Applications/Arduino.app/Contents/Java/tools/**",
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/**"
],
"forcedInclude": [
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h"
],
强制包含Arduino.h
具有以下相对包含:
// Some includes
#include <avr/pgmspace.h>
// Even more includes
问题是,尽管pgmspace.h
确实存在,但它并不位于相对于的路径中Arduino.h
(它也不位于两个包含路径之一中)。将路径添加pgmspace.h
到包含路径并没有帮助,因为 IntelliSense 似乎正在寻找给定的相对路径。
我的问题是是否有可能通过c_cpp_properties.json
文件告诉 IntelliSense 忽略相对路径并只查找文件?或者如果您能想出另一种方法来解决这个问题?
解决方案
我自己找到了答案。如果您有同样的问题,请尝试以下操作:
添加到settings.json
:
"C_Cpp.intelliSenseEngine": "Tag Parser"
这是一个缺点,因为“标签解析器”不是上下文感知的。
添加到c_cpp_properties.json
:
"configurations": [
{
...,
"browse": {
"path": [
"/Applications/Arduino.app/Contents/Java/tools",
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr",
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include"
],
"limitSymbolsToIncludedHeaders": true
}
}
]
推荐阅读
- mysql - MySQL查询删除包含超过10个字符的单词的条目
- c - 发送一个二维数组来计算总数并在函数中显示结果
- javascript - Head Meta Tag MusicKit JS 中的 Apple Developer Token
- firebase - 使用 httpsCallable() 调用 Firebase 云函数时出现 CORS 错误
- python - 如何创建新的唯一数据框
- sql - 在 Tableau 上创建 7 天实时仪表板
- python - 在列表中查找确切的单词
- c++ - 如何解决双向链表中的这些内存泄漏?
- google-sheets - 计算列中非空白单元格之间的连续空白单元格
- html - 如何在css中更改网格