C++ Debug Window showing "<incomplete type> for string variable

戏子无情 提交于 2019-12-10 13:29:49

问题


To my knowledge I'm initializing a string a fairly normal way and when I debug, the variables window in my IDE (CLion) shows its value as <incomplete type>. I have some simple code that results in the issue for the string variable Bob.

#include <iostream>

int main() {
    std::string Bob = "this doesn't show up in the variables window";
    std::cout << Bob << std::endl;
    return 0;
}

I don't know what impact it has but I'll include the CMakeLists file that appears to be the simplest that I can use.

cmake_minimum_required(VERSION 3.8)
project(testing123)

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

set(SOURCE_FILES main.cpp)
add_executable(testing123 ${SOURCE_FILES})

set(CMAKE_CXX_COMPILER "/cygdrive/c/cygwin64/bin/clang++")
set(CMAKE_C_COMPILER "/cygdrive/c/cygwin64/bin/clang++")

I looked at the other questions and they all had to do with classes and pointers which I can't see to be directly related, so if they are to blame for this, I'd appreciate an explanation as to how that would be.


回答1:


You might need to set debug mode using _GLIBCXX_DEBUG macro.

You can do this in a CMakeLists.txt file with the following line:

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")



来源:https://stackoverflow.com/questions/46782354/c-debug-window-showing-incomplete-type-for-string-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!