Hi everyone,
I am programming with the file server.c, client.c and network.c. The subject is a i am doing a simple chat tcp multi-threads. In other words, one thread per client and the following is the error:
leo@10-0-0-5:~/c2/mios/c-s-final$ make all
gcc -o server server.c -lpthread
/tmp/ccTZqeOu.o: In function `main':
server.c

.text+0x3cb): undefined reference to `passage'
collect2: ld devolvió el estado de salida 1
make: *** [server] Error 1
I am using arrays of structures (defined in network.h)
One part of the code:
/*************** server.c ***********************/
while(1) {
((s_client = accept(listenfd, (struct sockaddr *) &struc_server,
&t_server)) < 0);
if (s_client == MAX_USER) {
write(s_client, "Servidor lleno. Intente más tarde.", 35);
close(s_client);
}
else {
users[n_user].socket = s_client;
res = pthread_create(&(users[n_user].tid), &thread_attr, (void
*)passage, (void *)users[n_user].username);
if (res != 0) {
printf("error en pthread_create()");
exit(-1);
}
n_user++;
}
}
/************************ end server.c *****************************/
/*********************** network.h ************************/
#ifndef NETWORK_H
#define NETWORK_H
struct struc_user {
// char username[100]; //m usado en pthread_create
// int *number_user; //m usado en el accept
int socket;
char username[100]; // usado en pthread_create
pthread_t tid;
};
struct struc_user users[MAX_USER];
pthread_attr_t thread_attr; //atributos del hilo
void * passage(void *arg); //fc passage que retorna un argumento
/****************** end network.h************************/
PD: passage is the fc of the threads, which there is network.c, argv 3 of pthread_create.
the fc passage is more or less:
void *passage(void *arg){
.
.
}
What kind or errors is 'undefined reference to `passage'' ?
thx