can't use struct hsearch_data with sizeof

Discussion in 'C Programming' started by Damien MATTEI, Jul 6, 2004.

  1. #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:
     
    Damien MATTEI, Jul 6, 2004
    #1
    1. Advertising

  2. Damien MATTEI

    Alex Fraser Guest

    [OT] Re: can't use struct hsearch_data with sizeof

    "Damien MATTEI" <> wrote in message
    news:...
    > #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
     
    Alex Fraser, Jul 6, 2004
    #2
    1. Advertising

  3. Damien MATTEI

    -berlin.de Guest

    Damien MATTEI <> wrote:
    > #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
    --
    \ Jens Thoms Toerring ___ -berlin.de
    \__________________________ http://www.toerring.de
     
    -berlin.de, Jul 6, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Derek
    Replies:
    7
    Views:
    24,348
    Ron Natalie
    Oct 14, 2004
  2. Trevor

    sizeof(str) or sizeof(str) - 1 ?

    Trevor, Apr 3, 2004, in forum: C Programming
    Replies:
    9
    Views:
    640
    CBFalconer
    Apr 10, 2004
  3. Chris Fogelklou
    Replies:
    36
    Views:
    1,393
    Chris Fogelklou
    Apr 20, 2004
  4. Vinu
    Replies:
    13
    Views:
    1,440
    Lawrence Kirby
    May 12, 2005
  5. blufox

    sizeof( int ) != sizeof( void * )

    blufox, May 22, 2006, in forum: C Programming
    Replies:
    2
    Views:
    562
    Joe Smith
    May 22, 2006
Loading...

Share This Page