cancel
Showing results for 
Search instead for 
Did you mean: 

vscode + STM32CubeIDE,debug ,but 'optimized out'

brucegong
Associate III

When creating a project in STM32CubeMX, ST ARM Clang was selected. Compilation and debugging in VSCode all work, but some variables are optimized out, which seems like the compiler optimization is set too high. However, it's unclear where to set the compile flag -O0.

CMakeLists.txt like this, does not work

# Define the build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
endif()
 

截图 2025-12-30 08-27-35.png截图 2025-12-30 08-40-08.png

0 REPLIES 0