【发布时间】:2021-01-24 12:24:11
【问题描述】:
我有以下代码:
#include <iostream>
#include <string>
int main() {
std::string name = "Foo";
return 0;
}
当我使用lldb 进行调试时,我想设置一个std::string,就像我设置这个int:
expr int $num = 4
我试试:
expr std::string $name = "Foo"
我得到了:
error: no type named 'string' in namespace 'std'
有人知道发生了什么吗?如何在lldb 上创建std::string?
观察:
当我打印name 时,lldb 给我这个类型std::__1::string 为std::string:
p foo
(std::__1::string) $2 = "foo"
【问题讨论】:
-
std::string是std::basic_string<char>的别名,所以也许可行? -
@NikosC。没用,我得到了:
error: no template named 'basic_string' in namespace 'std' -
尝试使用返回给您的名称...在您的问题
std::__1::string -
所以尝试使用
const char *或const char[]或const char[5]。让我知道其中一个是否有效。 -
所以我在回答中转换评论以解决问题