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?

1
3 comments

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")

2
Avatar
Permanently deleted user

It worked! Thank you so much! happy new year!

0
Avatar
Permanently deleted user

Yes, Anna's method works.

But why is this not the default configuration? We are debugging!

 

0

Please sign in to leave a comment.