How to debug code with std::optional or std::variant? [closed]
Asked Answered
I

0

11

It doesn't matter if I use libc++, libstdc++ neither gdb nor lldb can visualise std::optional or std::variant. I have googled a little but I didn't come across an obvious solution.

Have I missed any pretty-printers?

Imperial answered 1/7, 2017 at 21:24 Comment(3)
My gdb can tell me this: "foo = std::experimental::optional<int> [no contained value]" for a optional<int> foo;. GNU gdb (GDB) 7.12.1 and g++ (GCC) 6.3.0 (test code compiled with -ggdb)Normative
Ah. I will test c++14 instead. Maybe the libstdc++ pretty printer is bound to namespace experimental.Imperial
I would guess that your optional is storage for T, then a bool byte, or vice versa. It shouldn't be hard to teach your debugger to read that...Bil

© 2022 - 2024 — McMap. All rights reserved.