vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Can't get "Code Analysis Mode" to work with ESP-IDF

Open Tomblarom opened this issue 1 year ago • 0 comments

Environment

OS: Windows 10 22H2 VS code: 1.86.2 C/C++ extension: 1.19.2 ESP-IDF: 5.2 ESP-IDF extension: 1.7.0 Python: 3.11.4

Disclaimer

Actually, I'm not sure if this is a bug or just a dumb newbie issue, but trying to troubleshoot took already way too long. I need proper support. And I contacted ESP-IDF devs first: https://github.com/espressif/vscode-esp-idf-extension/issues/1140

Description

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. 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:

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'

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-runner/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:

Include file not found in browse.path.C/C++
'stdio.h' file not found C/C++(clang-diagnostic-error)

Steps to Reproduce

  1. Create the sample "hello_world" project and open it
  2. Install C/C++ extension (if not done already)
  3. Fix IntelliSenseEngine according to this guide
  4. Add the following to settings.json:
"C_Cpp.codeAnalysis.runAutomatically": true,
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
  1. Now go to main.c and encounter the previously described error messages

Configuration and Logs

esp_idf_vsc_ext.log ESP-IDF.Doctor.command.log (includes verbose info, c_cpp_properties.json and launch.json)

Tomblarom avatar Feb 19 '24 10:02 Tomblarom