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.

  • 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 Mar 22 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 Mar 22 at 12:05
  • It does not matter if "" or <>. Thanks. – kk9527 Mar 22 at 22:35
  • Looking around. Seems by design for now. Pls see emacs.stackexchange.com/questions/47908/… – kk9527 Aug 5 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.