I need to add a watch in hexadecimal format in CLion.
ltoa(variable, 16)
doesn't work, at least, on my system.
In Java/Python, I can have a workaround: write a custom toString()
/__str__
for my class and have it displayed the way I need. gdb
has p/x
. How do I do it in CLion?
Edit: ltoa(variable, 16)
works if I define ltoa
in my code, as it's not always present in standard library.
set output-radix 16
You can set this as a default option in a file called .gdbinit
, which you can put in your home directory, or the working directory from which you start GDB (project root, for instance).
They added hex view as an experimental feature: Hexadecimal view
To enable:
Now the hexadecimal formatting is shown both in the Variables pane of the Debug tool window and in the editor's inline variables view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With