我有,我剛剛得知一個奇怪的問題。如果我在Visual Studio中運行此代碼,則會得到空/錯誤的輸出。但是當我在cLion中運行時,我只是碰到應用程序崩潰而沒有反饋。克利翁和CMake的不debugning /打印錯誤
VS錯誤:
Exception thrown: read access violation.
this was nullptr.
這裏是我的配置:
的main.cpp
#include <iostream>
using namespace std;
class testNothing {
public:
testNothing *test;
void donothing() { cout << test << endl; };
};
int main()
{
testNothing *hey = nullptr;
hey->donothing();
return 1;
};
CMakeList.txt
cmake_minimum_required(VERSION 3.8)
project(tests)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(SOURCE_FILES main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
不知道爲什麼你這個標記爲'debugging'當你似乎沒有嘗試任何......?打印運行時錯誤的程序不是「調試」;你需要自己調用它。 SO不是調試服務。 –