How do I view the value of an variable in C++?

前端 未结 4 1110
甜味超标
甜味超标 2020-12-08 02:33

I am using gdb to debug a C++ program.

I have this code:

int x = floor(sqrt(3));

and I want to view the value of x. However, gdb cl

4条回答
  •  生来不讨喜
    2020-12-08 03:06

    Create your own 'global variable' and print the optimized out variable into this global variable. Make sure to remove these globals created by you after you are done with the debugging!

提交回复
热议问题