使用Xcode时遇到的问题:nullptr_t错误

qv7cva1a  于 2023-06-24  发布在  其他
关注(0)|答案(1)|浏览(110)

我是XCode的新手,正在为一个名为Geant4的模拟软件做我的第一个项目。我有下面的C++代码,当我运行它时,我一直得到这个错误:

error: member 'nullptr_t' declared as a template 
_LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}

下面的代码包括一个CMakeLists.txt文件和一个sim.cc文件。问题似乎来自sim.cc文件。我做了一些阅读,这似乎是我的XCode版本(14. 3)的问题。我尝试添加路径到iostream,但没有解决问题。
有人有关于如何解决这个问题的建议吗?
CMakeLists.txt

cmake_minimum_required(VERSION 3.16...3.21 FATAL_ERROR)

project(Simulation)

find_package(Geant4 REQUIRED ui_all vis_all)

include(${Geant4_USE_FILE})

file(GLOB sources ${PROJECT_SOURCE_DIR}/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/*.hh)

add_executable(sim sim.cc ${sources} ${headers})
target_link_libraries(sim ${Geant4_LIBRARIES})

add_custom_target(Simulation DEPENDS sim)

sim.cc

#include <iostream>

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4VisManager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

int main(int argc, char** argv){
    G4RunManager *runManager = new G4RunManager();
    
    G4UIExecutive *ui = new G4UIExecutive(argc, argv);
    
    G4VisManager *visManager = new G4VisExecutive();
    visManager->Initialize();
    
    G4UImanager *UImanager = G4UImanager::GetUIpointer();
    
    ui->SessionStart();
    
    return 0;
}
piztneat

piztneat1#

我按照这些instructions成功地重新安装了Geant4。似乎存在编译器问题,Geant4没有正确的文件路径。上面的示例代码现在运行时不需要对代码进行任何更改。

相关问题