首先代码中包含eigen的matrix等变量时发现下面有红色波浪线,include路径也配置好了,头文件也能够找到,但是就是有波浪线,这个不是路径问题了。
https://github.com/microsoft/vscode-cpptools/issues/7413
这个链接解决了这个问题,其实是bug导致的,我们只需要按照如下操作
Experienced the same problem on M1 - for future reference a non-invasive way to propate fixes like #7413 (comment) without codebase changes seems to be by using forcedInclude
:
1. Create a file such as `.vscode/eigen_fix.h` containing the fix
#if __INTELLISENSE__
#undef __ARM_NEON
#undef __ARM_NEON__
#endif
2. Add it as a `forcedInclude` to the configuration in `.vscode/c_cpp_properties.json`
"forcedInclude": [
"${workspaceFolder}/.vscode/eigen_fix.h"
],
要注意的是上面这段放的位置,我提供一个我自己的c_cpp***文件供各位参考。
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include",
"/Library/Developer/CommandLineTools/usr/include/**",
"/usr/local/include/eigen3",
"/usr/local/include/opencv4"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64",
"forcedInclude": [
"${workspaceFolder}/.vscode/eigen_fix.h"
]
}
],
"version": 4
}
剩下的就是愉快的玩耍了,但是每个工程都需要这么弄,嗯。。。很垃圾