vscode-cpptools
vscode-cpptools copied to clipboard
IntelliSense reports incorrect errors when using eigen3 library
Bug type: Language Service
- OS and Version: Linux arm64 5.10.27-rt36-v8
- VS Code Version: 1.55.2
- C/C++ Extension Version: 1.3.1
I am programming with eigen3 library on vscode on Raspberry Pi 4B (64 bit Raspberry Pi OS) and here are the bugs: the IntelliSense reports errors after I create、fill、print a simple 2*2 matrix, but I can build and run the code , print the matrix correctly. I test these lines of codes in a x86 Ubuntu environment vscode, but no errors report. I also use different intelliSenseMode、Cppstandrad、compilerPath to test but it still reports errors.
Steps to reproduce
- Include the eigen library.
- Create a simple 2*2 matrix, fill it with integers and print it.
- See error.
Expected behavior IntelliSense should not mark these as errors.
Screenshots
the errors report:
the running result:

Additional context Also, although the eigen library autocomplete works, it lacks many options compared to vscode in x86 Ubuntu environment, are these bugs related? Thanks in advance!
Similar issues here.
- OS and Version: Ubuntu 18.04.5 LTS on Jetson Xavier (aarch64)
- VS Code Version: 1.55.2
- C/C++ Extension Version: 1.3.1
Got the following errors, however, the codes could be complied and run correctly.
I tested my codes in a 32 bit Raspberry Pi OS vscode, the incorrect errors disappear, I think probably the problem comes from the OS?
@AlBrP and @lordofutopia Could you provide the following logs to help us further investigate?
-
Logs from running
C/C++: Log Diagnosticsfrom the VS Code command palette -
Logs from enabling the language server logging
Here are the logs from running C/C++: Log Diagnostics from the VS Code command palette:

Here are the logs from enabling the language server logging:

Hope I have understood you correctly.
Here are mine. C/C++: Log Diagnostics
-------- Diagnostics - 4/23/2021, 9:17:05 PM
Version: 1.3.1
Current Configuration:
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/eigen3",
"/usr/local/include",
"/usr/include/"
],
"defines": [],
"compilerPath": "/usr/bin/aarch64-linux-gnu-g++",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-arm64",
"compilerArgs": [],
"intelliSenseModeIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"compilerPathIsExplicit": true,
"browse": {
"path": [
"${workspaceFolder}/**",
"/usr/include/eigen3",
"/usr/local/include",
"/usr/include/"
],
"limitSymbolsToIncludedHeaders": true
}
}
Translation Unit Mappings:
[ /home/zaas/Test/eigen_test/helloworld.cpp ]:
/home/zaas/Test/eigen_test/helloworld.cpp
Translation Unit Configurations:
[ /home/zaas/Test/eigen_test/helloworld.cpp ]:
Process ID: 9601
Memory Usage: 202 MB
Compiler Path: /usr/bin/aarch64-linux-gnu-g++
Includes:
/usr/include/eigen3
/usr/include/c++/7
/usr/include/aarch64-linux-gnu/c++/7
/usr/include/c++/7/backward
/usr/lib/gcc/aarch64-linux-gnu/7/include
/usr/local/include
/usr/lib/gcc/aarch64-linux-gnu/7/include-fixed
/usr/include/aarch64-linux-gnu
/usr/include
Standard Version: c++14
IntelliSense Mode: linux-gcc-arm64
Other Flags:
--g++
--gnu_version=70500
Total Memory Usage: 202 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 19557
Language logging server output:
File exclude: **/.vscode
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/*.code-search
Populate include completion cache.
Discovering files...
Processing folder (recursive): /usr/include/
Processing folder (recursive): /usr/lib/gcc/aarch64-linux-gnu/7/include/
Processing folder (recursive): /usr/lib/gcc/aarch64-linux-gnu/7/include-fixed/
Processing folder (recursive): /usr/local/include/
Processing folder (recursive): /home/zaas/Test/eigen_test/
Processing folder (recursive): /usr/include/eigen3/
Discovering files: 19557 file(s) processed
0 file(s) removed from database
Done discovering files.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
idle loop: reparsing the active document
Checking for syntax errors: file:///home/zaas/Test/eigen_test/helloworld.cpp
Queueing IntelliSense update for files in translation unit of: /home/zaas/Test/eigen_test/helloworld.cpp
Error squiggle count: 8
Update IntelliSense time (sec): 0.274
idle loop: reparsing the active document
Checking for syntax errors: file:///home/zaas/Test/eigen_test/helloworld.cpp
Queueing IntelliSense update for files in translation unit of: /home/zaas/Test/eigen_test/helloworld.cpp
Error squiggle count: 8
Update IntelliSense time (sec): 0.273
IntelliSense Engine = Default.
Enhanced Colorization is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Autocomplete is enabled.
cpptools/didChangeCppProperties
$/setTraceNotification
Here are mine. C/C++: Log Diagnostics
-------- Diagnostics - 4/23/2021, 9:17:05 PM Version: 1.3.1 Current Configuration: { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/usr/include/eigen3", "/usr/local/include", "/usr/include/" ], "defines": [], "compilerPath": "/usr/bin/aarch64-linux-gnu-g++", "cStandard": "gnu11", "cppStandard": "gnu++14", "intelliSenseMode": "linux-gcc-arm64", "compilerArgs": [], "intelliSenseModeIsExplicit": true, "cStandardIsExplicit": true, "cppStandardIsExplicit": true, "compilerPathIsExplicit": true, "browse": { "path": [ "${workspaceFolder}/**", "/usr/include/eigen3", "/usr/local/include", "/usr/include/" ], "limitSymbolsToIncludedHeaders": true } } Translation Unit Mappings: [ /home/zaas/Test/eigen_test/helloworld.cpp ]: /home/zaas/Test/eigen_test/helloworld.cpp Translation Unit Configurations: [ /home/zaas/Test/eigen_test/helloworld.cpp ]: Process ID: 9601 Memory Usage: 202 MB Compiler Path: /usr/bin/aarch64-linux-gnu-g++ Includes: /usr/include/eigen3 /usr/include/c++/7 /usr/include/aarch64-linux-gnu/c++/7 /usr/include/c++/7/backward /usr/lib/gcc/aarch64-linux-gnu/7/include /usr/local/include /usr/lib/gcc/aarch64-linux-gnu/7/include-fixed /usr/include/aarch64-linux-gnu /usr/include Standard Version: c++14 IntelliSense Mode: linux-gcc-arm64 Other Flags: --g++ --gnu_version=70500 Total Memory Usage: 202 MB ------- Workspace parsing diagnostics ------- Number of files discovered (not excluded): 19557Language logging server output:
File exclude: **/.vscode File exclude: **/.git File exclude: **/.svn File exclude: **/.hg File exclude: **/CVS File exclude: **/.DS_Store Search exclude: **/node_modules Search exclude: **/bower_components Search exclude: **/*.code-search Populate include completion cache. Discovering files... Processing folder (recursive): /usr/include/ Processing folder (recursive): /usr/lib/gcc/aarch64-linux-gnu/7/include/ Processing folder (recursive): /usr/lib/gcc/aarch64-linux-gnu/7/include-fixed/ Processing folder (recursive): /usr/local/include/ Processing folder (recursive): /home/zaas/Test/eigen_test/ Processing folder (recursive): /usr/include/eigen3/ Discovering files: 19557 file(s) processed 0 file(s) removed from database Done discovering files. Parsing remaining files... Parsing: 0 files(s) processed Done parsing remaining files. idle loop: reparsing the active document Checking for syntax errors: file:///home/zaas/Test/eigen_test/helloworld.cpp Queueing IntelliSense update for files in translation unit of: /home/zaas/Test/eigen_test/helloworld.cpp Error squiggle count: 8 Update IntelliSense time (sec): 0.274 idle loop: reparsing the active document Checking for syntax errors: file:///home/zaas/Test/eigen_test/helloworld.cpp Queueing IntelliSense update for files in translation unit of: /home/zaas/Test/eigen_test/helloworld.cpp Error squiggle count: 8 Update IntelliSense time (sec): 0.273 IntelliSense Engine = Default. Enhanced Colorization is enabled. Error squiggles are enabled if all header dependencies are resolved. Autocomplete is enabled. cpptools/didChangeCppProperties $/setTraceNotification
Hi lordofutopia, have you solved your problem? My vscode instellsense still have bugs...... 😭
I repro the issue after setting "compilerPath": "/usr/bin/aarch64-linux-gnu-g++" and using code
#include <eigen3/Eigen/Eigen>
#include <iostream>
using namespace std;
int main()
{
Eigen::Matrix<int, 2, 2> a;
a << 2,2,2,2;
cout << a << endl;
return 0;
}
It's advisable to remove all the references to system includes from your includePath (except for possibly subfolders like /usr/include/eigen3) because otherwise the system include paths could possibly be in the wrong order, but that doesn't appear to be causing the bug here.
Adding this at the top of the source file
#if __INTELLISENSE__
#undef __ARM_NEON
#undef __ARM_NEON__
#endif
fixes the issue for me -- can you confirm?
The problem appears that our IntelliSense parser does not recognize any of the intrinsic types (and functions) found in the arm_neon.h header, so it causes a cascading amount of errors for everything based on those types that don't exist.
I will file a feature request on our VS parser to add support for those.
Adding this at the top of the source file
#if __INTELLISENSE__ #undef __ARM_NEON #undef __ARM_NEON__ #endiffixes the issue for me -- can you confirm?
The problem appears that our IntelliSense parser does not recognize any of the intrinsic types (and functions) found in the arm_neon.h header, so it causes a cascading amount of errors for everything based on those types that don't exist.
I will file a feature request on our VS parser to add support for those.
My issue is fixed by adding these lines. Many thanks.
Adding this at the top of the source file
#if __INTELLISENSE__ #undef __ARM_NEON #undef __ARM_NEON__ #endiffixes the issue for me -- can you confirm?
The problem appears that our IntelliSense parser does not recognize any of the intrinsic types (and functions) found in the arm_neon.h header, so it causes a cascading amount of errors for everything based on those types that don't exist.
I will file a feature request on our VS parser to add support for those.
Oh the errors disappear, Thanks a lot! By the way, how can I know if the vscode has been added support for arm_neon.h?
I've filed a bug on our shared VS parser at https://developercommunity.visualstudio.com/t/C-IntelliSense-doesnt-work-correctly/1408223 . You'll know if/when it's fixed via monitoring that issue or this issue, but depending on our schedule it may take a few weeks to ship a release with the new parser changes after VS has a fix.
I've filed a bug on our shared VS parser at https://developercommunity.visualstudio.com/t/C-IntelliSense-doesnt-work-correctly/1408223 . You'll know if/when it's fixed via monitoring that issue or this issue, but depending on our schedule it may take a few weeks to ship a release with the new parser changes after VS has a fix.
Sincerely Thanks for your help!
same here under ARM Mac (M1) using Eigen library:
- VS Code Version: 1.58 (insiders)
- OS Version: macOS BigSur 11.2.3
- c++ extension 1.4.1
Steps to Reproduce:
- Intellisense won't see the classes defined in the Eigen Library, which is included inside the workspace folder
- Attached is the screenshot of a simple header, where the issue is visible and the c_cpp_properties.json configuration used
- code compiles well
- Same code under the intel-mac shows correct intellisense behaviour
- Earlier version of the extension (1.2.0) works correctly under ARM mac, although the intellisense mode has to be set up as
"clang-x64"
@chumaroz Your issue might be different. Is it fixed after following https://github.com/microsoft/vscode-cpptools/issues/7413#issuecomment-827172897 ? If not, can you inspect the definition of Eigen::MatrixXd to see what could be causing our parser to skip parsing that definition? If you can preprocess the file via a command like "/usr/bin/clang++ -std=gnu++20 -E -dD <any needed -I> defines_eigen.hpp > defines_eigen.out.cpp" (or use whatever source file you expect to be used), then you might be able to see what is the root cause of the error, i.e. in one of the dependent headers (note that some errors in the preprocessed files are "expected" and can be ignored).
Hi @sean-mcmanus, I had a similar problem as @chumaroz. Can confirm that #7413 (comment) fixes the problem for me.
I have recently just come across this issue on an arm64 (M1) linux machine. It was a rabbit hole finding the root cause which turned out to be intellisense + eigen. The suggested temporary patch from https://github.com/microsoft/vscode-cpptools/issues/7413#issuecomment-827172897 alleviated the issue when propagated across the entire project.
I will also note that there has been no updates on the issue listed elsewhere https://developercommunity.visualstudio.com/t/C-IntelliSense-doesnt-work-correctly/1408223.
It would be a worthwhile feature to find and show root files that have intellisense errors as they propagate in strange ways. i.e. std::shared_ptr not being found when the root cause something else.
Experienced the same problem on M1 - for future reference a non-invasive way to propate fixes like https://github.com/microsoft/vscode-cpptools/issues/7413#issuecomment-827172897 without codebase changes seems to be by using forcedInclude:
- Create a file such as
.vscode/eigen_fix.hcontaining the fix
#if __INTELLISENSE__
#undef __ARM_NEON
#undef __ARM_NEON__
#endif
- Add it as a
forcedIncludeto the configuration in.vscode/c_cpp_properties.json
"forcedInclude": [
"${workspaceFolder}/.vscode/eigen_fix.h"
],
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__ #endif2. Add it as a `forcedInclude` to the configuration in `.vscode/c_cpp_properties.json`"forcedInclude": [ "${workspaceFolder}/.vscode/eigen_fix.h" ],
I like the unobtrusive strategy that you've suggested. A global entry can be applied to your settings.json
"C_Cpp.default.forcedInclude": ["/path/eigen_fix.h"]" for better applicability across multiple projects.
I have unfortunately found it doesn't work for my use case due to taking advantage of compile_commands.json in my intellisense configuration. The file is not included when intellisense uses compile_commands.json for the particular file. Turning off this usage the fix works as expected.
I have found an old ticket https://github.com/microsoft/vscode-cpptools/issues/1842 describing that it is expected behaviour, although undocumented as far as I can see in the schema https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference.
@globalhuman Your issue with forcedInclude not working with compile_commands.json is being track by https://github.com/microsoft/vscode-cpptools/issues/8274, so you could upvote that.
Hello - a note that using the forcedInclude trick appears to have recently stopped working for me (I reported this issue separately in #9510).
However, adding the #if __INTELLISENSE__ block directly to my header where I include Eigen does seem to work. I don't think I changed anything on my end in the last couple of months that would have affected this.
Any word on an upstream fix to the parser?
@spinicist forcedInclude should work the same as if you directly included the code. We're not currently aware of any bug with forcedInclude not working. The upstream parser fix (adding arm neon support) sounds like it might be a far off goal, because it's a major work item and they're working on other major work items, like c++20 modules and c++23.
Apologies, forcedInclude does now appear to be working for me. I swear I was getting red squiggles only two days ago. Chalk this up as a false positive, I'll report back if I see it again.
Sorry I'm new here, I appear to have exactly the same issues as mentioned in this thread, but no method listed above works in my case. I'm working on a GitHub project using clang, including :
#if __INTELLISENSE__
#undef __ARM_NEON
#undef __ARM_NEON__
#endif
on top of the headers doesn't work, even creating a new file Eigen_fix.h and forceInclude doesn't change anything.
Do you know any other solutions ? My code does compile and execute because I'm using Conan, but coding in such a way makes it difficult to see errors.
@EarltShirt Can you run C/C++: Log Diagnostics and verify it looks as expected for the file giving errors?
@sean-mcmanus , just runned one and everything looked fine to me (and to my teacher):
-------- Diagnostics - 08/03/2023, 13:44:40
Version: 1.14.4
Current Configuration:
{
"name": "Mac",
"includePath": [
"/Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/**"
],
"forcedInclude": [
"/Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/.vscode/eigen_fix.h"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64",
"configurationProvider": "ms-vscode.cmake-tools",
"compilerPathIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": true,
"mergeConfigurations": false,
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Custom browse configuration:
{
"browsePath": [
"/users/earltshirt/documents/universite/m1s2/ue projet/projet-cpp-git-alglib-earltshirt/include",
"/users/earltshirt/.conan/data/catch2/3.3.1/_/_/package/f569384322632fbce9a2d419692e9c6d2ce75b78/include",
"/users/earltshirt/documents/universite/m1s2/ue projet/projet-cpp-git-alglib-earltshirt/test",
"/users/earltshirt/.conan/data/docopt.cpp/0.6.2/_/_/package/d807749d60b62b9be75e90d4e9db2893d0314632/include",
"/users/earltshirt/.conan/data/fmt/6.2.1/_/_/package/d807749d60b62b9be75e90d4e9db2893d0314632/include",
"/users/earltshirt/.conan/data/spdlog/1.5.0/_/_/package/09ef3b4d5eeef06472bbb936f61b30e0b55b26c0/include",
"/users/earltshirt/.conan/data/eigen/3.4.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/eigen3",
"/users/earltshirt/documents/universite/m1s2/ue projet/projet-cpp-git-alglib-earltshirt/src"
],
"compilerPath": "/usr/bin/clang++",
"compilerArgs": [],
"compilerFragments": [
"-O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk",
"-fcolor-diagnostics",
"-Wall",
"-Wextra",
"-Wshadow",
"-Wnon-virtual-dtor",
"-Wold-style-cast",
"-Wcast-align",
"-Wunused",
"-Woverloaded-virtual",
"-Wpedantic",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference",
"-Wdouble-promotion",
"-Wformat=2",
"-Werror",
"-std=gnu++17"
]
}
Custom configurations:
[ /Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/src/main.cpp ]
{
"includePath": [
"/users/earltshirt/documents/universite/m1s2/ue projet/projet-cpp-git-alglib-earltshirt/include",
"/users/earltshirt/.conan/data/docopt.cpp/0.6.2/_/_/package/d807749d60b62b9be75e90d4e9db2893d0314632/include",
"/users/earltshirt/.conan/data/fmt/6.2.1/_/_/package/d807749d60b62b9be75e90d4e9db2893d0314632/include",
"/users/earltshirt/.conan/data/spdlog/1.5.0/_/_/package/09ef3b4d5eeef06472bbb936f61b30e0b55b26c0/include",
"/users/earltshirt/.conan/data/eigen/3.4.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/eigen3"
],
"defines": [
"SPDLOG_COMPILED_LIB",
"SPDLOG_FMT_EXTERNAL"
],
"compilerPath": "/usr/bin/clang++",
"compilerArgs": [],
"compilerFragments": [
"-O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk",
"-fcolor-diagnostics",
"-std=gnu++17"
]
}
Translation Unit Mappings:
[ /Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/src/main.cpp ]:
/Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/src/main.cpp
/Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/include/MSE.cpp *
Translation Unit Configurations:
[ /Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/src/main.cpp ]:
Process ID: 82183
Memory Usage: 374 MB
Compiler Path: /usr/bin/clang++
Includes:
/Users/earltshirt/Documents/universite/M1S2/UE PROJET/projet-cpp-git-alglib-earltshirt/include
/Users/earltshirt/.conan/data/docopt.cpp/0.6.2/_/_/package/d807749d60b62b9be75e90d4e9db2893d0314632/include
/Users/earltshirt/.conan/data/fmt/6.2.1/_/_/package/d807749d60b62b9be75e90d4e9db2893d0314632/include
/Users/earltshirt/.conan/data/spdlog/1.5.0/_/_/package/09ef3b4d5eeef06472bbb936f61b30e0b55b26c0/include
/Users/earltshirt/.conan/data/eigen/3.4.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/eigen3
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
Frameworks:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
Defines:
SPDLOG_COMPILED_LIB
SPDLOG_FMT_EXTERNAL
NDEBUG
Standard Version: c++17
IntelliSense Mode: macos-clang-arm64
Other Flags:
--clang
--clang_version=110000
Total Memory Usage: 374 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3414
@EarltShirt Actually, your logging indicates you have a configurationProvider set, and therefore it is not using the forcedInclude which works around this issue (the section below "Translation Unit Configurations: " shows what is actually used). You need to either get your configuration provider to set the forcedInclude, or add "mergeConfigurations": true" to add the forcedInclude, but you may want to remove your includePath initially in case that might interfere with the includePaths coming from your configuration provider.
Thanks a lot @sean-mcmanus ! Was trying to solve this problem since months !