can't use struct hsearch_data with sizeof

D

Damien MATTEI

#include <search.h>
[...]
struct hsearch_data htab_ports;
[...]
memset (&htab_ports, 0, sizeof (struct hsearch_data));


gives errors:

snif.c:153: error: storage size of `htab_ports' isn't known
[...]
snif.c:2057: error: invalid application of `sizeof' to an incomplete type


any help will be greatly appreciated



please, copy carbon reply to: (e-mail address removed)
 
A

Alex Fraser

Damien MATTEI said:
#include <search.h>

Non-standard header.
[...]
struct hsearch_data htab_ports;
[...]
memset (&htab_ports, 0, sizeof (struct hsearch_data));

gives errors:

snif.c:153: error: storage size of `htab_ports' isn't known

<OT> Try #define _GNU_SOURCE like it says on the manpage. </OT>

Alex
 
J

Jens.Toerring

Damien MATTEI said:
#include <search.h>
[...]
struct hsearch_data htab_ports;
[...]
memset (&htab_ports, 0, sizeof (struct hsearch_data));
gives errors:
snif.c:153: error: storage size of `htab_ports' isn't known
[...]
snif.c:2057: error: invalid application of `sizeof' to an incomplete type

<search.h> isn't a standard C header file, so it's hard to say what
is going wrong beside that obviously "struct htsearch_data" isn't
defined anywhere where the compiler can find it.

<OT>
If you're compiling this under some kind of Linux you may have
to #define _GNU_SOURCE to get the compiler to see what that
structure is. Send further question to comp.unix.programmer
in that case, please.
</OT>
Regards, Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top