espressif / vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/
Apache License 2.0
1.06k stars 304 forks source link

ESP_LOGI, uintXX_t undefined or syntax error in intelliSense (VSC-1427) #1246

Closed louisjonathan closed 4 months ago

louisjonathan commented 4 months ago

OS

Linux

Operating System version

Ubuntu 24.04 LTS

Visual Studio Code version

1.90.1

ESP-IDF version

5.5.2

Python version

3.12

Doctor command output

---------------------------------------------- ESP-IDF Extension for Visual Studio Code report --------------------------------------------- OS linux x64 6.8.0-36-generic System environment variable IDF_PYTHON_ENV_PATH undefined System environment variable PATH

/.local/bin:/.cargo/bin:/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin System environment variable PYTHON undefined Visual Studio Code version 1.90.1 Visual Studio Code language en Visual Studio Code shell /usr/bin/bash ESP-IDF Extension version 1.8.0 Workspace folder /Desktop/Research/jl-research-summer-2024/Pasteables_Software/ESP32C3/CUI_V2 ---------------------------------------------------- Extension configuration settings ------------------------------------------------------ ESP-ADF Path (idf.espAdfPath) ${env:ADF_PATH} ESP-IDF Path (idf.espIdfPath) /esp/esp-idf ESP-MDF Path (idf.espMdfPath) ${env:MDF_PATH} ESP-Matter Path (idf.espMatterPath) ${env:ESP_MATTER_PATH} ESP-HomeKit-SDK Path (idf.espHomeKitSdkPath) ${env:HOMEKIT_PATH} Custom extra paths (idf.customExtraPaths) /.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin:/.espressif/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin:/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin:/.espressif/tools/esp-rom-elfs/20230320 Custom extra vars (idf.customExtraVars) OPENOCD_SCRIPTS: /.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts ESP_ROM_ELF_DIR: /.espressif/tools/esp-rom-elfs/20230320/ Virtual env Python Path (idf.pythonBinPath) /.espressif/python_env/idf5.2_py3.12_env/bin/python Serial port (idf.port) /dev/ttyS4 OpenOCD Configs (idf.openOcdConfigs) board/esp32-wrover-kit-3.3v.cfg ESP-IDF Tools Path (idf.toolsPath) /.espressif Git Path (idf.gitPath) git Notification Mode (idf.notificationMode) All -------------------------------------------------------- Configurations access ------------------------------------------------------------- Access to ESP-ADF Path (idf.espAdfPath) false Access to ESP-IDF Path (idf.espIdfPath) true Access to ESP-MDF Path (idf.espMdfPath) false Access to ESP-Matter Path (idf.espMatterPath) false Access to ESP-HomeKit Path (idf.espHomeKitSdkPath) false Access to ESP-IDF Custom extra paths Access to /.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin: true Access to /.espressif/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin: true Access to /.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin: true Access to /.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin: true Access to /.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin: true Access to /.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin: true Access to /.espressif/tools/esp-rom-elfs/20230320: true Access to Virtual env Python Path (idf.pythonBinPath) true Access to CMake in environment PATH true Access to Ninja in environment PATH true Access to ESP-IDF Tools Path (idf.toolsPath) true -------------------------------------------------------- Configurations has spaces ------------------------------------------------------------- Spaces in system environment Path false Spaces in ESP-ADF Path (idf.espAdfPath) false Spaces in ESP-IDF Path (idf.espIdfPath) false Spaces in ESP-MDF Path (idf.espMdfPath) false Spaces in ESP-Matter Path (idf.espMatterPath) false Spaces in ESP-HomeKit-SDK Path (idf.espHomeKitSdkPath) false Spaces in ESP-IDF Custom extra paths Spaces in /.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin: false Spaces in /.espressif/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin: false Spaces in /.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin: false Spaces in /.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin: false Spaces in /.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin: false Spaces in /.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin: false Spaces in /.espressif/tools/esp-rom-elfs/20230320: false Spaces in Virtual env Python Path (idf.pythonBinPath) false Spaces in ESP-IDF Tools Path (idf.toolsPath) false ----------------------------------------------------------- Executables Versions ----------------------------------------------------------- Git version 2.43.0 ESP-IDF version 5.2.2 Python version 3.12.2 Python's pip version 24.1.2 -------------------------------------------------- Project configuration settings ---------------------------------------------------------- -------------------------------------------------- Python packages in idf.pythonBinPath ---------------------------------------------------- bitarray version: 2.9.2 bitstring version: 4.2.3 CacheControl version: 0.14.0 certifi version: 2024.6.2 cffi version: 1.16.0 charset-normalizer version: 3.3.2 click version: 8.1.7 colorama version: 0.4.6 construct version: 2.10.70 contextlib2 version: 21.6.0 cryptography version: 41.0.7 ecdsa version: 0.19.0 esp-coredump version: 1.11.0 esp-idf-kconfig version: 1.4.2 esp-idf-monitor version: 1.4.0 esp-idf-panic-decoder version: 1.1.0 esp-idf-size version: 1.5.0 esptool version: 4.7.0 filelock version: 3.15.4 freertos-gdb version: 1.0.3 idf-component-manager version: 1.5.3 idna version: 3.7 intelhex version: 2.3.0 kconfiglib version: 14.1.0 markdown-it-py version: 3.0.0 mdurl version: 0.1.2 msgpack version: 1.0.8 packaging version: 24.1 pip version: 24.1.2 pyclang version: 0.4.2 pycparser version: 2.22 pyelftools version: 0.31 pygdbmi version: 0.11.0.0 Pygments version: 2.18.0 pyparsing version: 3.1.2 pyserial version: 3.5 PyYAML version: 6.0.1 reedsolo version: 1.7.0 requests version: 2.32.3 requests-file version: 1.5.1 requests-toolbelt version: 1.0.0 rich version: 13.7.1 schema version: 0.7.5 setuptools version: 70.2.0 six version: 1.16.0 tqdm version: 4.66.4 urllib3 version: 1.26.19 ---------------------------------------------------- Check ESP-IDF python requirements.txt ------------------------------------------------- Check ESP-IDF Python packages Python requirements are satisfied. ---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------ Check Debug AdapterPython packages Error ---------------------------------------------------- Visual Studio Code launch.json -------------------------------------------------------- { "version": "0.2.0", "configurations": [ { "type": "gdbtarget", "request": "attach", "name": "Eclipse CDT GDB Adapter" }, { "type": "espidf", "name": "Launch", "request": "launch" } ] } ---------------------------------------------------- Visual Studio Code c_cpp_properties.json ---------------------------------------------- { "configurations": [ { "name": "ESP-IDF", "compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc", "compileCommands": "${config:idf.buildPath}/compile_commands.json", "includePath": [ "${config:idf.espIdfPath}/components/**", "${config:idf.espIdfPathWin}/components/**", "${workspaceFolder}/**" ], "browse": { "path": [ "${config:idf.espIdfPath}/components", "${config:idf.espIdfPathWin}/components", "${workspaceFolder}" ], "limitSymbolsToIncludedHeaders": true } } ], "version": 4 } ----------------------------------------------------------- Latest error ----------------------------------------------------------------- { "code": 1, "killed": false, "signal": null, "cmd": "/.espressif/python_env/idf5.2_py3.12_env/bin/python /esp/esp-idf/tools/check_python_dependencies.py -r /.vscode/extensions/espressif.esp-idf-extension-1.8.0/esp_debug_adapter/requirements.txt" } ### Extension excluded for brevity. ### Description Forgive me if I missed a duplicate issue, I promise I searched for similar issues. **Issue:** ESP-IDF VS Code extension does not recognize some types and adds red squigglies under things that do not even raise warnings when building with `idf.py build`. I have looked at [c_cpp configuration "guide"](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/C_CPP_CONFIGURATION.md) and even copied default .json files into the project. ****Configurations:**** ![image](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/219dd1b9-e78a-4305-96f2-73fee19e4474) current c_cpp_properties.json ![Screenshot from 2024-07-08 18-22-45](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/85df60c6-64d6-4970-a8b8-40e65d8a8a81) current settings.json ![image](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/4689c3c6-81cb-4803-a93e-09e9a16ee37a) current ./main/CMakeLists.txt **Best Guess:** I believe the unrecognized types are due to some error in intelliSense mistakenly thinking that the types are already defined. most of the `uintXX_t` are "undefined" to intelliSense, but defined to idf.py ![image](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/bd4f9f63-d4e7-48a0-9599-3dc06ca9191f) ![image](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/adc4a104-0f29-47e6-a360-7816961b25d7) ![image](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/ba06ade4-674a-46bf-b76f-17f4391c62b9) There is definitely something fishy going on here. The ESP_LOGX commands have `expected ')'` as the reason for the "error", but again, idf.py compiles them without even a warning. ![image](https://github.com/espressif/vscode-esp-idf-extension/assets/97409787/1b9e4cb0-02c6-46ba-be61-2bb0100319ab) (above code is shamelessly lifted off of [espressif's ble gap server](https://github.com/espressif/esp-idf/tree/v5.2.2/examples/bluetooth/bluedroid/ble/gatt_security_server) so it is correct, and to reiterate: `idf.py build` is successful for this project) ### Debug Message ```plain N/A ``` ### Other Steps to Reproduce _No response_ ### I have checked existing issues, online documentation and the Troubleshooting Guide - [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.
brianignacio5 commented 4 months ago

As you might have seen, this Language configuration is not done by our extension but we provide template for the Microsoft C/C++ extension which is the one extension that provide language support.

I'm trying to reproduce your issue without success. I'm using IDF v5.2.2 with the linked example you provided and the intellisense works well for me on macOS. Screenshot 2024-07-09 at 09 42 40 Screenshot 2024-07-09 at 09 42 55

Could it be the file associations in your settings.json?

louisjonathan commented 4 months ago

sorry for the late response. I will try to move the source files to a new template, if that doesn't work, I will post here and then likely reinstall everything.

louisjonathan commented 4 months ago

here's what I did that (I think) fixed it

ESP-IDF extension -> create new project ESP-IDF terminal -> . ~/esp/esp-idf/export.sh ESP-IDF terminal -> idf.py set-target esp32c3 (at this point headers like esp_bt.h are not found) settings.json -> change

              "idf.openOcdConfigs": [
                      "board/esp32-wrover-kit-3.3v.cfg"
                  ],
  to 
          ```
          "idf.openOcdConfigs": [
                  "board/esp32c3-builtin.cfg"
              ],
          ```

ESP-IDF terminal -> idf.py menuconfig (re-enable all of my previous settings manually, just to be sure) ESP-IDF terminal -> idf.py clean

(at this point all the errors are gone, all headers are found, and all types and macros are properly identified by intelliSense)

ESP-IDF terminal -> idf.py build

I will reopen this if somehow the issues come back and update it does