我正在尝试将 OpenMPI 的 mpi.h 的重要部分翻译成 D 编程语言,以便我可以从 D 调用它。(HTOD 根本不起作用。)我无法理解以下内容代码位:
typedef struct ompi_communicator_t *MPI_Comm;
OMPI_DECLSPEC extern struct ompi_communicator_t ompi_mpi_comm_world;
OMPI_DECLSPEC extern struct ompi_communicator_t ompi_mpi_comm_self;
OMPI_DECLSPEC extern struct ompi_communicator_t ompi_mpi_comm_null;
问题是 ompi_communicator_t
从未在 mpi.h 中定义,并且 mpi.h 不包含除 stddef.h 之外的任何其他文件,这显然不包含定义。 (评论说它包含在 ptrdiff_t
中。)这是 mpi.h 中仅有的四行包含字符串 ompi_communicator_t
。这个结构的定义来自哪里?有什么技巧我应该知道类型可以凭空出现吗? (还有其他几个类似的结构,但这是我偶然发现的第一个。)
最佳答案
这是一个指向结构的指针,其内部在 OpenMPI 之外是不可见的。使用任何可以容纳指针的类型,例如(在 C 中)void*
。
关于c - mpi.h : Using a type w/o defining it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6945728/