VSCODE reports symbols not found, while jump to declaration works correctly.
Environment
Version: 1.89.1 (user setup) Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:13:33.891Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Windows_NT x64 10.0.22621
C/C++ version: v1.20.5 CMake Tools version: v1.17.17
Bug Summary and Steps to Reproduce
- CMake is used as a configuration provider
- CMake successfully compiles the project,
adc.cfile is part of the compilation. I can see it in thecompile_commands.jsoncmake output - I cannot find
C/C++: Log Diagnosticscommand, but there isCMake: Log Diagnosticscommand, exported below - Control+CLICK on the
#include "adc.h"does not work, but CTRL+CLICK on theADC_HandleTypeDefdoes open the declaration. You can see them on the picture below, lines1and6 -
adc.cis added to the project through the subdirectory, through the interface library
CMake diagnostics
{
"os": "win32",
"vscodeVersion": "1.89.1",
"cmtVersion": "1.17.17",
"configurations": [
{
"folder": "c:\\path\\to\\project",
"cmakeVersion": "3.28.1",
"configured": true,
"generator": "Ninja",
"usesPresets": true,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [
"file:///c%3A/path/to/project/source/crypto.c",
"file:///c%3A/path/to/project/source/iwdg.c",
"file:///c%3A/path/to/project/source/system_stm32u5xx.c",
"file:///c%3A/path/to/project/source/flashif.c",
"file:///c%3A/path/to/project/app/source/adc.c",
"file:///c%3A/path/to/project/lib/drivers/STM32U5xx_HAL_Driver/Inc/stm32u5xx_hal_adc.h",
"file:///c%3A/path/to/project/lib/drivers/CMSIS/Device/ST/STM32U5xx/Include/stm32u575xx.h",
"file:///c%3A/path/to/project/app/source/i2c.c",
"file:///c%3A/path/to/project/lib/drivers/STM32U5xx_HAL_Driver/Inc/stm32u5xx_hal_i2c.h"
],
"responses": [
{
"uri": "file:///c%3A/path/to/project/source/crypto.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/source/iwdg.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/source/system_stm32u5xx.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/source/flashif.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/app/source/adc.c",
"configuration": {
"includePath": [],
"defines": [],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-g++.exe",
"compilerArgs": [],
"compilerFragments": []
}
},
{
"uri": "file:///c%3A/path/to/project/app/source/i2c.c",
"configuration": {
"includePath": [],
"defines": [],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-g++.exe",
"compilerArgs": [],
"compilerFragments": []
}
}
],
"partialMatches": [],
"targetCount": 5,
"executablesCount": 1,
"librariesCount": 3,
"targets": [
{
"name": "app",
"type": "INTERFACE_LIBRARY"
},
{
"name": "cJSON",
"type": "INTERFACE_LIBRARY"
},
{
"name": "file_rebuilder_always",
"type": "UTILITY"
},
{
"name": "application3_firmware",
"type": "EXECUTABLE"
},
{
"name": "stm32_hal_driver",
"type": "INTERFACE_LIBRARY"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
Configuration and Logs
{
"version": 4,
"configurations": [
{
"name": "STM32",
"configurationProvider": "ms-vscode.cmake-tools",
"intelliSenseMode": "${default}"
}
]
}
Other Extensions
No response
Additional context
adc.c and i2c.c seem to have empty response by CMake Tools extension. They are added to the project as an external library to the main application, like so:
add_subdirectory("app" app)
target_link_libraries(${CMAKE_PROJECT_NAME} app)
And then CMakeLists.txt in the app folder looks like so:
cmake_minimum_required(VERSION 3.22)
# Register core library
add_library(app INTERFACE)
target_include_directories(app INTERFACE
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/include/lib
)
# Add all
file(GLOB_RECURSE sources ${CMAKE_CURRENT_LIST_DIR}/source/*.c)
target_sources(app PUBLIC ${sources})
# Add cJSON library to the build
add_subdirectory("../lib/cJSON" cJSON)
target_link_libraries(app INTERFACE cJSON)
@MaJerle C/C++: Log Diagnostics should appear when you have a C/C++ file active.
I agree, thanks. it is below.
Some notes:
- CMake tools does not use GCC from mingw, but compiler is ARM GCC instead. Not sure why it shows path to msys64 (I have GCC compiler there, but we don't compile target with this one)
- file
iwdg.cis added to the target withtarget_sourcescmake functions. This file works fine - file
adc.cis added to the target viaadd_subdirectory(...)and then we link the library from the subdirectory. This file has problems
There is clearly a disrepancy.
I tested same project with 2 different computers and result is always the same.
-------- Diagnostics - 5/24/2024, 8:01:02 PM
Version: 1.20.5
Current Configuration:
{
"name": "STM32",
"configurationProvider": "ms-vscode.cmake-tools",
"intelliSenseMode": "windows-gcc-x64",
"compilerPathIsExplicit": false,
"cStandardIsExplicit": false,
"cppStandardIsExplicit": false,
"intelliSenseModeIsExplicit": false,
"configurationProviderInCppPropertiesJson": "ms-vscode.cmake-tools",
"includePath": [
"C:\\msys64\\mingw64\\include\\c++\\12.2.0",
"C:\\msys64\\mingw64\\include\\c++\\12.2.0\\x86_64-w64-mingw32",
"C:\\msys64\\mingw64\\include\\c++\\12.2.0\\backward",
"C:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include",
"C:\\msys64\\mingw64\\include",
"C:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include-fixed",
"C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include"
],
"macFrameworkPath": [],
"cStandard": "c17",
"cppStandard": "gnu++17",
"mergeConfigurations": false,
"compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"browse": {
"path": [
"C:\\msys64\\mingw64\\include\\c++\\12.2.0",
"C:\\msys64\\mingw64\\include\\c++\\12.2.0\\x86_64-w64-mingw32",
"C:\\msys64\\mingw64\\include\\c++\\12.2.0\\backward",
"C:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include",
"C:\\msys64\\mingw64\\include",
"C:\\msys64\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include-fixed",
"C:\\msys64\\mingw64\\x86_64-w64-mingw32\\include",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
}
Custom browse configuration:
{
"browsePath": [
"c:/path/to/project/app/source",
"c:/path/to/project/app/source/lib",
"c:/path/to/project/lib/cjson",
"c:/path/to/project/build/app/cmakefiles",
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/lib/cjson/include",
"c:/path/to/project/source",
"c:/path/to/project/lib/mbedtls/library",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/src",
"c:/path/to/project/lib/lwprintf/src/lwprintf"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-g++.exe",
"compilerArgs": [],
"compilerFragments": []
}
cpptools version (native): 1.20.5.0
Translation Unit Mappings:
[ C:\path\to\project\app\source\adc.c - source TU]:
[ C:\path\to\project\bootloader\source\bootloader.c - source TU]:
[ C:\path\to\project\source\iwdg.c - source TU]:
C:\path\to\project\include\iwdg.h
C:\path\to\project\lib\drivers\STM32U5xx_HAL_Driver\Inc\stm32u5xx_hal_adc.h
Translation Unit Configurations:
[ C:\path\to\project\app\source\adc.c ]:
Process ID: 41012
Memory Usage: 52 MB
Compiler Path: C:\ST\STM32CubeCLT\GNU-tools-for-STM32\bin\arm-none-eabi-g++.exe
Includes:
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\lib\gcc\arm-none-eabi\12.3.1\include
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\lib\gcc\arm-none-eabi\12.3.1\include-fixed
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\arm-none-eabi\include
Standard Version: c17
IntelliSense Mode: windows-gcc-arm
Other Flags:
--gcc
--gnu_version=120301
[ C:\path\to\project\source\iwdg.c ]:
Process ID: 32976
Memory Usage: 102 MB
Compiler Path: C:\ST\STM32CubeCLT\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe
Includes:
C:\path\to\project\include
C:\path\to\project\lib\drivers\CMSIS\Device\ST\STM32U5xx\Include
C:\path\to\project\lib\drivers\CMSIS\Include
C:\path\to\project\lib\mbedtls\include
C:\path\to\project\lib\drivers\STM32U5xx_HAL_Driver\Inc
C:\path\to\project\lib\drivers\STM32U5xx_HAL_Driver\Inc\Legacy
C:\path\to\project\lib\lwprintf\src\include
C:\path\to\project\build\app\lwprintf\lib_inc
C:\path\to\project\app\include
C:\path\to\project\app\include\lib
C:\path\to\project\lib\cJSON\include
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\arm-none-eabi\include\newlib-nano
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\lib\gcc\arm-none-eabi\12.3.1\include
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\lib\gcc\arm-none-eabi\12.3.1\include-fixed
C:\ST\STM32CubeCLT\GNU-tools-for-STM32\arm-none-eabi\include
Defines:
APP_FW_MAX_LEN=0x00060000
APP_FW_START_OFFSET=0x00000400
APP_LOAD_ADDR=0x08020000
BOOTLOADER_FW_MAX_LEN=0x00020000
BOOTLOADER_LOAD_ADDR=0x08000000
DEBUG
DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000
DOWNLOAD_SLOT_LOAD_ADDR=0x08080000
IS_APP=1
IS_BOOTLOADER=0
IS_DEVELOPMENT=0
STM32U575xx
USE_FULL_LL_DRIVER
USE_HAL_DRIVER
VERSION_FW_MAJOR=0
VERSION_FW_MINOR=0
VERSION_FW_PATCH=1
VERSION_FW_REV=0
VERSION_FW_TYPE=0
VERSION_HW_MAJOR=0
VERSION_HW_MINOR=0
VERSION_HW_PATCH=0
Standard Version: c11
IntelliSense Mode: windows-gcc-arm
Other Flags:
--gcc
--gnu_version=120301
Total Memory Usage: 209 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3788
Update: for test, I moved from the add_subdirectory approach, to file(GLOB_RECURSE...) instead.
Now all files are added to the project as a target, and not as a library anymore.
And it works fine.
Is it therefore vscode-cmake-tools issue?
@MaJerle I think so. From your logging, I don't see a configuration being sent from CMake Tools.
Edit: No, after I closed the window and opened again, it stopped working again, regardless of how cmake is configured.
@MaJerle Sorry, I thought our Log Diagnostics logging showed the "Custom configurations received:" logging but it's actually in our main C/C++ logging when C_Cpp.loggingLevel is set to "Debug". Do you see the correct "Custom configurations received:" info being sent from CMake Tools? i.e. the correct includes/defines/args/compilerFragments.
I'm not getting correct data if I well understood your point.
I'm testing on 2 PCs, same project, and something seems to be wrong with CMake Tools extension, because suddenly it starts working (random) and as soon as I restart vscode, errors appear again
@MaJerle We apologize for getting back to you so late. We are trying to reproduce your issue but we can't reproduce it based on the information you provided, could you provide your reproduction project?
Please feel free if you have any doubt!