Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have worked some hours, but i can't solved it,
so please tell me why?

in the lxhttpd_netbase.h
CSS
/**
  handle read/write callback.
*/
typedef void ( *read_write_cb )( int fd, void *arg );
struct fd_set;
struct timeval;
/**
  a tcp server.
*/
struct tcp_server
{
        // socket: file descriptor
        int fd;
        // fd set
        struct fd_set *fd_readset;
        struct fd_set *fd_writeset;
        struct fd_set *fd_set;
        // max connection
        int max_con;
        // read/write callback
        read_write_cb read_cb;
        read_write_cb write_cb;
        // argument for read/write callback
        void *arg;
};



in the lxhttpd_netbase.c
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <netinet/in.h>
#include <string.h>
#include "lxhttpd_netbase.h"
#include <unistd.h>

/*
  set fd set
*/
static void _server_set_fd( struct tcp_server *server )
{
        memcpy( server->fd_readset->fd_array, server->fd_set->fd_array, sizeof( server->fd_set->fd_array[0] ) * server->fd_set->fd_count );
        server->fd_readset->fd_count = server->fd_set->fd_count;
        memcpy( server->fd_writeset->fd_array, server->fd_set->fd_array, sizeof( server->fd_set->fd_array[0] ) * server->fd_set->fd_count );
        server->fd_writeset->fd_count = server->fd_set->fd_count;
        FD_SET( server->fd, server->fd_readset );
        //FD_SET( server->fd, server->fd_writeset );
}




and when i complier it by gcc -o lxhttpd_netbase -g lxhttpd_netbase.c
it will come out :
VB
lxhttpd_netbase.c: In function_server_set_fd’:
lxhttpd_netbase.c:46: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:46: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:46: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:46: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:47: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:47: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:48: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:48: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:48: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:48: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:49: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:49: error: dereferencing pointer to incomplete type
lxhttpd_netbase.c:50: error: dereferencing pointer to incomplete type



please help me, thank you very much.

i have included the files in the lxhttpd_netbase.h :
XML
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>


but it still don't work. thank you
Posted
Updated 20-Feb-11 3:27am
v4

Probably, it is the lack of a firm definition of fd_set - your lxhttpd_netbase.h file defines it as:
struct fd_set;
Try to include the file containing the full definition, and the error should disappear.

At the moment, you try to access the server->fd_readset->fd_array etc. elements of your tcp_server structure, but the compiler doesn't know anything about them!
 
Share this answer
 
Comments
Espen Harlinn 20-Feb-11 8:11am    
Good answer :)
lxlenovostar 20-Feb-11 9:19am    
i try to include the fowllowing files,but it doesn't work

#include ???
#include ???
#include <stdlib.h>
#include <stdio.h>
#include ???
#include <string.h>
#include <unistd.h>
OriginalGriff 20-Feb-11 9:21am    
Would you mind rephrasing that? :laugh:
I suspect that your less than and grater than characters are being swallowed by the HTML: edit your question and add this at teh end in a code block.
Sergey Alexandrovich Kryukov 20-Feb-11 15:19pm    
I edited your text. You need to use HTML char entities, not angular brackets (edit again to see source text). You lost three includes (I marked ???) before I had a chance to help it. Please edit again.
--SA
lxlenovostar 20-Feb-11 9:25am    
sorry , i will do it .
if i must use fd_set in this way , i must include "Winsock2.h",
in linux, we can't use fd_cout and fd_array. because fd_set is:
#undef __NFDBITS
#define __NFDBITS       (8 * sizeof(unsigned long))
 
#undef __FD_SETSIZE
#define __FD_SETSIZE    1024
 
#undef __FDSET_LONGS
#define __FDSET_LONGS   (__FD_SETSIZE/__NFDBITS )
typedef struct {
          unsigned long fds_bits [__FDSET_LONGS];
  } fd_set;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900