Can't get esp-clang (clang-tidy) to work with Code Analysis Mode of VS Code C/C++ extension
Posted: Sun Feb 18, 2024 9:04 am
Hello, I'm struggeling to get the automatic "Code Analysis Mode" of C/C++ extension to work. I downloaded and installed the latest ESP-IDF v5.2 through the VS Code IDF extension and additionally did it a second time through the online-installer 2.24.
I installed the C/C++ extension, opened the hello_world project and got this message:
To fix it, I followed this guide for IDF. With this I'm able to successfully compile. However my environment lacks live/automatic "Code Analysis Mode" (when I write false C/C++ code it's not beeing detected). By default its on "Manual" and I tried to enable "C_Cpp.codeAnalysis.clangTidy.enabled": true, but this results in random expections like this:
I found a few issues that are related to my issue, but I can't get figure how to make their solutions work in my environment..
- https://github.com/espressif/clang-tidy ... /issues/36
- https://github.com/espressif/esp-idf/issues/6868
I tried to install the IDF Tool "Clang-Tidy" or esp-tidy, was not able to properly attach it to the C/C++ extension. I tried to change the compilerPath in "c_cpp_properties.json" to "${config:idf.toolsPathWin}\\tools\\esp-clang\\16.0.1-fe4f10a809\\esp-clang\\bin\\clang.exe (or clang++.exe or clang-tidy.exe)", which lead to these exceptions:
I installed the C/C++ extension, opened the hello_world project and got this message:
Code: Select all
"c:\Users\X390\Drive\DEV_Design\Own\hello_world\hello_world/build/compile_commands.json" could not be parsed.
'includePath' from c_cpp_properties.json in folder 'HELLO_WORLD' will be used instead.
Code: Select all
Error while processing C/C++(clang-diagnostic-error)
rv_utils.h(52, 5): use of undeclared identifier 'asm'
rv_utils.h(61, 5): use of undeclared identifier 'asm'
rv_utils.h(82, 5): use of undeclared identifier 'asm'
rv_utils.h(92, 12): use of undeclared identifier 'asm'
csr.h(166, 3): expanded from macro 'RV_READ_CSR'
rv_utils.h(102, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(128, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(150, 28): use of undeclared identifier 'asm'
csr.h(180, 3): expanded from macro 'RV_CLEAR_CSR'
rv_utils.h(152, 5): use of undeclared identifier 'asm'
csr.h(176, 3): expanded from macro 'RV_SET_CSR'
rv_utils.h(158, 28): use of undeclared identifier 'asm'
csr.h(180, 3): expanded from macro 'RV_CLEAR_CSR'
rv_utils.h(160, 5): use of undeclared identifier 'asm'
csr.h(176, 3): expanded from macro 'RV_SET_CSR'
rv_utils.h(232, 5): use of undeclared identifier 'asm'
csr.h(176, 3): expanded from macro 'RV_SET_CSR'
rv_utils.h(237, 5): use of undeclared identifier 'asm'
csr.h(180, 3): expanded from macro 'RV_CLEAR_CSR'
rv_utils.h(285, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(286, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(287, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(288, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(297, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(298, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
rv_utils.h(299, 5): use of undeclared identifier 'asm'
csr.h(169, 3): expanded from macro 'RV_WRITE_CSR'
- https://github.com/espressif/clang-tidy ... /issues/36
- https://github.com/espressif/esp-idf/issues/6868
I tried to install the IDF Tool "Clang-Tidy" or esp-tidy, was not able to properly attach it to the C/C++ extension. I tried to change the compilerPath in "c_cpp_properties.json" to "${config:idf.toolsPathWin}\\tools\\esp-clang\\16.0.1-fe4f10a809\\esp-clang\\bin\\clang.exe (or clang++.exe or clang-tidy.exe)", which lead to these exceptions:
Code: Select all
Include file not found in browse.path.C/C++
'stdio.h' file not found C/C++(clang-diagnostic-error)