我想知道字符串的工作原理,所以我在basic_string.h中添加了断点。
但是当我调试时它并没有进入这些断点。

当我在调试时添加断点时,GDB控制台显示以下内容:
文件“ C:/Users/manch/Downloads/MinGW/lib/gcc/mingw32/4.8.1/include/c ++ / bits / basic_string.h”中没有第1008行。

enter image description here

这是我的测试代码

#include <iostream>
#include <string>

int main() {
    std::string *ps = new std::string("hello");
    ps->append(" world");
    return 0;
}


和CMakeLists.txt

cmake_minimum_required(VERSION 3.6)
project(Stl)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp test.cpp  C:/Users/manch/Downloads/MinGW/lib/gcc/mingw32/4.8.1/include/c++/bits/stl_construct_copy.h)
add_executable(Stl ${SOURCE_FILES})

最佳答案

您还需要为Mincc链接可执行文件的标准C ++库libstdc++提供源文件。然后,根据this问题,您将需要在编译时添加-D_GLIBCXX_DEBUG标志,以便链接具有调试信息的库。

关于c++ - Clion调试:如何进入STL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40904158/

10-11 22:52
查看更多