我正在尝试编写一个包装 MPI 的框架库。
我有一个名为 afw.h
的框架头文件和一个名为 afw.c
的框架实现文件。
我希望能够通过在应用程序代码中执行 #include "afw.h"
来编写使用该框架的应用程序代码。
afw.h
的摘录:
#ifndef AFW_H
#define AFW_H
#include <mpi.h>
struct ReqStruct
{
MPI_Request req;
};
ReqStruct RecvAsynch(float *recvbuf, FILE *fp);
int RecvTest(ReqStruct areq);
我在 afw.c
中为 RecvAsynch
提供了一个实现,其中 #includes afw.h
当我使用 mpicc
进行编译时(在本例中是一个 MPI 编译器包装器,在下面使用 pgc):
mpicc -c afw.c -o afw.o
我得到:
PGC-S-0040-Illegal use of symbol, ReqStruct (./afw.h: 69)
PGC-W-0156-Type not specified, 'int' assumed (./afw.h: 69)
PGC-S-0040-Illegal use of symbol, ReqStruct (./afw.h: 71)
PGC-W-0156-Type not specified, 'int' assumed (./afw.h: 71)
以及 afw.c
中使用 ReqStruct
的类似错误
知道我做错了什么吗?
最佳答案
您定义了一个struct ReqStruct
,而不是ReqStruct
,它们不是一回事。
要么把函数改成
struct ReqStruct RecvAsynch(float *recvbuf, FILE *fp);
或者使用 typedef:
typedef struct ReqStruct ReqStruct;
关于c - header 编译错误中的结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10013286/