gpt4 book ai didi

C++未知调用约定

转载 作者:太空狗 更新时间:2023-10-29 20:19:44 24 4
gpt4 key购买 nike

我正在构建的一个包(SPRNG,链接是 here 但对于这个问题是不必要的)在一些我不熟悉的地方使用了调用语法。对于我以前的依赖堆栈(Intel 16.0 和 OpenMPI 1.10.1),它有效。不幸的是,我当前的堆栈(带有 OpenMPI 3.1.3 的英特尔 19)不喜欢它。我不是 c++ 的人,除非必须,否则我也不想大幅修改包。

示例代码为:

#include <mpi.h>

int main(int argc, char *argv[]) {
int myid;

MPI::Init(argc, argv);
myid = MPI::COMM_WORLD.Get_rank();
}

在之前的堆栈中,这似乎没问题:

$ mpic++ --version
icpc (ICC) 16.0.0 20150815
Copyright (C) 1985-2015 Intel Corporation. All rights reserved.

$ mpirun --version
mpirun (Open MPI) 1.10.1

Report bugs to http://www.open-mpi.org/community/help/
$ mpic++ sprng_issue.cpp
<no errors>

但是有了新的堆栈:

$ mpic++ --version
icpc (ICC) 19.0.1.144 20181018
Copyright (C) 1985-2018 Intel Corporation. All rights reserved.

$ mpirun --version
mpirun (Open MPI) 3.1.3

Report bugs to http://www.open-mpi.org/community/help/
$ mpic++ sprng_issue.cpp
sprng_issue.cpp(6): error: name followed by "::" must be a class or namespace name
MPI::Init(argc, argv);
^

sprng_issue.cpp(7): error: name followed by "::" must be a class or namespace name
myid = MPI::COMM_WORLD.Get_rank();
^

compilation aborted for sprng_issue.cpp (code 2)

我的问题是:

  1. 这个调用方法有名字吗?我在搜索时遇到了麻烦,因为它只是。它有多奇怪/古老/不标准?

  2. 是否有编译器标志(Intel 或其他)来启用遗留行为?

  3. 关于在不大幅修改包代码的情况下轻松通过的任何其他建议?

最佳答案

C++ 绑定(bind)在多年前就已从标准中删除,它们不再默认构建在 Open MPI 中。

从长远来看,您应该对代码进行现代化改造(使用纯 C 绑定(bind)或其他抽象层,例如 Boost.MPI)。

同时,您可以使用 configure --enable-mpi-cxx 简单地重建 Open MPI。

关于C++未知调用约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56784501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com