#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

typedef void withdrawPtr(int);
typedef void depositPtr(int);
typedef void accountPtr(int);
typedef void deltaccountPtr();
int balance;
pthread_mutex_t mutex1;

实际上我已经把一个等价的c++代码转换成了c代码
typedef struct
{
   int (*read)();
   withdrawPtr *withdraw;
   depositPtr *deposit;
   accountPtr *account;
   deltaccountPtr *deltaccount;

} accountstrct;


 void  *WithdrawThread(void *param)
{
struct accountstrct*  Mystruct = (struct accountstrct*) param;

这里我得到了指向不完整类型的解引用指针。我不知道还有什么办法可以取消这里的功能。?
Mystruct->withdrawPtr=*withdraw ;
Mystruct->withdrawPtr(2);
return 0;
   }

最佳答案

您从未定义过struct accountstrct。将类型定义为struct accountstrct { };并使用struct accountstrct引用该类型,或者将类型定义为typedef struct {} accountstrct;并使用accountstrct引用该类型(而不是“struct accountscrct”)。
您当前定义了一个名为accountstrct的类型,但您正在尝试使用一个名为struct accountstrct的类型。

关于c - 每次运行此代码时,我都会取消引用不完整的类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7894406/

10-16 14:32