struct가 충돌하는 것 같은데 어떻게 고쳐야 할지 모르겠습니다.

shdthwnd722의 이미지

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define SERV_TCP_PORT 60000
#define SERV_ADDR "165.246.38.151"
void handle_state2(int x, fd_set * pset, char *buf, struct client *cli);
struct client
{
char name[20];
int state;
int partner;
};
void handle_state2(int x, fd_set * pset, char *buf, struct client *cli)
{
if(strcmp(buf, "") == 0)
{
printf_error(x, &pset);
}
cli[x]->name = buf;
write(x, "ready?\nyes/no", 5);
}
이렇게 하면
servping.c:131:6: error: conflicting types for ‘handle_state2
이런 에러가 뜨는데 struct가 문제인걸로 추측이되는데 정확히는 잘 모르겠습니다... 도와주세요

Hodong Kim@Google의 이미지

이렇게 하면 되지 않을까요?

struct client
{
  char name[20];
  int state;
  int partner;
};
 
void handle_state2 (int x, fd_set * pset, char *buf, struct client *cli)
{
  if(strcmp(buf, "") == 0)
    printf_error(x, &pset);
 
  cli[x]->name = buf;
  write(x, "ready?\nyes/no", 5);
}
shdthwnd722의 이미지

잘 모르겠는데요

Hodong Kim@Google의 이미지

void handle_state2(int x, fd_set * pset, char *buf, struct client *cli);
struct client 가 나오는데 그게 위에 있어야 할 거에요.

Hodong Kim@Google의 이미지

void handle_state2 (int x, fd_set * pset, char *buf, struct client *cli);
 
struct client
{
  char name[20];
  int state;
  int partner;
};
 
void handle_state2 (int x, fd_set * pset, char *buf, struct client *cli)
{
  if(strcmp(buf, "") == 0)
    printf_error(x, &pset);
 
  cli[x]->name = buf;
  write(x, "ready?\nyes/no", 5);
}

struct client
{
  char name[20];
  int state;
  int partner;
};
 
void handle_state2 (int x, fd_set * pset, char *buf, struct client *cli);
 
void handle_state2 (int x, fd_set * pset, char *buf, struct client *cli)
{
  if(strcmp(buf, "") == 0)
    printf_error(x, &pset);
 
  cli[x]->name = buf;
  write(x, "ready?\nyes/no", 5);
}

struct client
{
  char name[20];
  int state;
  int partner;
};
 
void handle_state2 (int x, fd_set * pset, char *buf, struct client *cli)
{
  if(strcmp(buf, "") == 0)
    printf_error(x, &pset);
 
  cli[x]->name = buf;
  write(x, "ready?\nyes/no", 5);
}