0

Suppose I've this code:

#include "map"
#include "string"
using namespace std;
int main () {
    map<string, string> m = {{"1", "2"}};
    return 0;
}

If I set BP at "return 0" and when it's hit, local windows shows:

std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > m <complex data type>

On the other hand, in gdb windows, "p m" can print out "$1 = std::map with 1 element = {["1"] = "2"}". Speedbar can shows the correct value too.

When gdb debugging, can local window in emacs show c++ object's value correct, same as speedbar?

(Speedbar is not convenient because I need manually add/remove data.)

Thanks.

4
  • Ref your code: "map" and "string" are system includes files, it should be #include <map>(similar for string) unless you may have a special reason to store them locally in your project's folder. Does your program compile ok?
    – Ian
    Commented Mar 22, 2019 at 8:06
  • @Ian The code compiles. #include <map> just means that only the system directories are searched for "map". #include "map" searches more directories than #include <map>.
    – Tobias
    Commented Mar 22, 2019 at 12:05
  • It does not matter if "" or <>. Thanks.
    – kgflying
    Commented Mar 22, 2019 at 22:35
  • Looking around. Seems by design for now. Pls see emacs.stackexchange.com/questions/47908/…
    – kgflying
    Commented Aug 5, 2019 at 18:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.