variables optimized out when debugging
Answered

just like the picture, some varibles are optimized out when debugging, but I'm confused what cause that? why I can't see this varible's value?
Please sign in to leave a comment.
Hi!
On high optimization levels, the compiler can eliminate intermediate values, as you have seen here. Please see this stackoverflow discussion, for example. To change the optimization level, add the following commands to CMakeLists.txt file:
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
It worked! Thank you so much! happy new year!
Yes, Anna's method works.
But why is this not the default configuration? We are debugging!