当指向struct的aux指针的内容为"AAAAA“时,我想停止执行。
typedef struct Matriz {
string *usuario;
string *produto;
string nota;
Matriz *proxima_linha, *proxima_coluna;
} Matriz;
Matriz *aux = new Matriz();首先,我在aux声明后面放了一个断点。
breakpoint set --file UsuariosSemelhantes.cpp --line 55
然后我定义了一个观察点。
watchpoint set variable aux
然后我添加了停止条件。
watchpoint modify -c '(int)strcmp(*aux->usuario,"AAAAA") == 0'
但我得到以下错误:
Process 398158 resuming
Stopped due to an error evaluating condition of watchpoint Watchpoint 1: addr = 0x7fffffffe620 size = 8 state = enabled type = w: "(int)strcmp(*aux->usuario,"AAAAA") == 0"
error: <user expression 0>:1:13: cannot pass object of non-trivial type 'std::string' (aka 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >') through variadic function; call will abort at runtime
(int)strcmp(*aux->usuario,"AAAAA") == 0
^发布于 2020-10-31 02:45:13
条件必须是有效的C++表达式。不能将std::string传递给strcmp,需要传递char *。如果你在代码中尝试这样做,你也会得到一个错误。
因为您有一个std::string,所以使用std::string方法可能是最简单的方法:
aux->usuario->compare("AAAAA") == 0https://stackoverflow.com/questions/64601702
复制相似问题