mpi.h: Using a type w/o defining it?

丶灬走出姿态 提交于 2019-12-05 01:57:20

问题


I'm trying to translate the important parts of OpenMPI's mpi.h to the D programming language so I can call it from D. (HTOD didn't work at all.) I can't wrap my head around the following bits of code:

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;

The problem is that ompi_communicator_t is never defined in mpi.h and mpi.h doesn't include any other file besides stddef.h, which clearly doesn't contain a definition. (The comment says it's included for ptrdiff_t.) These are the only four lines in mpi.h that contain the string ompi_communicator_t. Where is the definition of this struct coming from? Are there any tricks I should be aware of where types can appear out of thin air? (There are several other structs like this, but this is the first one I stumbled upon.)


回答1:


This is a pointer to the struct, which internals are not visible outside the OpenMPI. Use any type which can hold a pointer, e.g. (in C) void*.



来源:https://stackoverflow.com/questions/6945728/mpi-h-using-a-type-w-o-defining-it

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