Code for Concinnity

“Pretty-printing” STL vector in Eclipse CDT

It’s surprising to see why the C++ debugging scene in Mac/Linux is so behind Visual Studio. One definite strengths of MSVS is the ability to display STL vectors as arrays in the debug view.

If you’re using Eclipse CDT on Mac, you’re probably stuck with GDB 6.8 which doesn’t come with pretty printing. I tried self building GDB 7.2 but Eclipse CDT 8.0 doesn’t seem to be able to interact well with it (please someone come and correct me if I’m wrong).

So here’s how to display std::vector nicely even if you’re using GDB 6.8:

As you can see, the trick is to convert it to a pointer and to use the array syntax *((int*)nums) @ 3

Enjoy 🙂

Published by kizzx2, on July 3rd, 2011 at 12:37 pm. Filled under: UncategorizedNo Comments

No comments yet.

Leave a Reply