这是我写的一个结构。
typedef struct {
int index=NULL;
int sd;
pthread_t tid;
char* name;
}client_t;
接下来,我正在制作这些结构的数组。
static client_t *clients[MAXCLIENTS];
现在在主函数中,我根据数组中的位置为这些结构分配值。
clients[freeslot]->index=freeslot;
clients[freeslot]->sd=connfd;
clients[freeslot]->tid=syscall(SYS_gettid);
clients[freeslot]->name=threadnames[freeslot];
当我编译时,我收到这些错误消息。
code.c:185:12: error: ‘client_t’ has no member named ‘index’
code.c:186:19: error: ‘client_t’ has no member named ‘sd’
code.c:187:19: error: ‘client_t’ has no member named ‘tid’
code.c:188:19: error: ‘client_t’ has no member named ‘name’
我对这些错误消息感到困惑。我是否以错误的方式分配了值?