我想用VS Code开发Arduino代码。因此,我安装了Arduino IDE和Arduino扩展vor VS Code。
在VS Code中打开Arduino项目时,扩展名为IntelliSense创建了以下c_cpp_properties.json
文件(摘录):
"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"
这是一个缺点,因为“ 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
}
}
]