Differences is using netdb.h with the cc and gcc compilers.

Ask a Question related to AIX, Design and Development.

  1. #1

    Default Differences is using netdb.h with the cc and gcc compilers.

    I have a small 'C' program that wraps up the netdb.h headers on
    multiple
    platforms. The AIX version of this code compiles beautifully using
    the AIX
    cc compiler. However, I've recently downloaded gcc and am trying to
    port
    over to using the gcc compiler on all the platforms I can get it
    working on.
    The problem I am having is that my wrapper code that compiles and
    tests just
    fine when using the cc compiler, will not compile under gcc. Here is
    the
    command line for the cc compile:

    cc -c -g -DAIX -qthreaded -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__
    net.c

    The command for the gcc compile is (slightly different):

    gcc -c -g -DAIX -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__
    -D_XOPEN_SOURCE=5
    00L -D_THREAD_SAFE -pthread net.c

    After which I get the following errors:
    net.c: In function `host_make_by_address':
    net.c:141: error: storage size of `he_data' isn't known
    net.c:161: error: invalid application of `sizeof' to an incomplete
    type
    net.c: In function `host_make_by_name':
    net.c:203: error: storage size of `he_data' isn't known
    net.c:217: error: invalid application of `sizeof' to an incomplete
    type
    net.c: In function `protocol_make_by_name':
    net.c:478: error: storage size of `pr_data' isn't known
    net.c:491: error: invalid application of `sizeof' to an incomplete
    type
    net.c: In function `protocol_make_by_number':
    net.c:521: error: storage size of `pr_data' isn't known
    net.c:534: error: invalid application of `sizeof' to an incomplete
    type
    net.c: In function `service_make_by_port':
    net.c:627: error: storage size of `sp_data' isn't known
    net.c:640: error: invalid application of `sizeof' to an incomplete
    type
    net.c: In function `service_make_by_name':
    net.c:671: error: storage size of `sp_data' isn't known
    net.c:684: error: invalid application of `sizeof' to an incomplete
    type


    A small section of the code (just for the host_make_by_address
    function -
    and with all the non-relevant ifdefs removed) is here:

    ================================================== =======================
    DLL_EXPORT
    host host_make_by_address(const char *address) {
    host result = 0;
    struct hostent *he = 0;
    int addr = 0;

    int err_num = 0;
    struct hostent he_hold;
    struct hostent_data he_data;

    addr = inet_addr(address);
    if (addr != -1) {
    memset(&he_data, 0, sizeof(struct hostent_data));
    if (gethostbyaddr_r((char *)&addr, sizeof(addr),
    AF_INET,
    &he_hold, &he_data) == 0) {
    he = &he_hold;
    } else {
    err_num = errno;
    }

    if (he) {
    result = host_make_from_hostent(he);
    } else {
    error_set_format(1, 128, "Error in
    gethostbyaddr_r:
    %d",
    err_num);
    }
    } else {
    error_set_format(1, 128, "%s is not a valid IP
    address",
    address
    );
    }

    return result;
    }
    ================================================== =========================

    The main issue is that all of the
    struct Xent_data
    structures are not seen as being defined when compiling with gcc.

    For the life of me, I cannot understand how the cc compiler sees them
    as
    defined where gcc cannot (especially when the definitions for gcc are
    a super-set of the definitions of cc).

    Any ideas?

    Thanks.

    Ravi
    Ravi Desai Guest

  2. Similar Questions and Discussions

    1. intel compilers
      Has anyone tried install intel's compilers on 6.04? My 'replacement headers' install, but the compiler fails to install. There is No error...
    2. I just want to know the differences :0)
      Hi All Is it me or is it sooo difficult to find what has been implemented between versions of the MySQL Administrator tool? I've looked all...
    3. Differences between FH MX and ...
      Hi guys- I consider myself a newbie to Freehand MX and am clueless when it comes to the "print" world. Eventually, I'd like to do print projects...
    4. CS and 7 differences
      Hey guys, I currently have CS and v7 of PS. I want to buy a training DVD course and have the option of getting CS and v7. v7 is only 99.00 while CS...
    5. header/include files and compilers
      Hi everyone, When writing a program (say, work.c), I could simply include header files using, for example: #include <stdio.h> and "gcc...
  3. #2

    Default Re: Differences is using netdb.h with the cc and gcc compilers.

    Ravi Desai wrote:
    > The main issue is that all of the
    > struct Xent_data
    > structures are not seen as being defined when compiling with gcc.
    >
    > For the life of me, I cannot understand how the cc compiler sees them
    > as
    > defined where gcc cannot (especially when the definitions for gcc are
    > a super-set of the definitions of cc).
    gcc uses its own copy of some system header files. Maybe your gcc
    installation is using its own netdb.h?

    Jeff Trawick Guest

  4. #3

    Default Re: Differences is using netdb.h with the cc and gcc compilers.

    Jeff Trawick <trawick@attglobal.net> wrote in message news:<uzo9b.11376$ft.7064@twister.southeast.rr.com >...
    > Ravi Desai wrote:
    > > The main issue is that all of the
    > > struct Xent_data
    > > structures are not seen as being defined when compiling with gcc.
    > >
    > > For the life of me, I cannot understand how the cc compiler sees them
    > > as
    > > defined where gcc cannot (especially when the definitions for gcc are
    > > a super-set of the definitions of cc).
    >
    > gcc uses its own copy of some system header files. Maybe your gcc
    > installation is using its own netdb.h?
    Thanks for the reply - I've searched (the entire system, actually) for
    all netdb.h files. There are no other ones than the one in
    /usr/include. It appears that the only #ifdef that could be
    interfering with the definition is an #ifdef _ALL_SOURCE.
    Unfortunately, setting that flag on results in more issues than I care
    to talk about, a _huge_ section of code cannot compile. I'm a bit
    flummoxed, really, the cc compiler MUST be setting that flag
    internally (unless it has some version of netdb.h buried away
    somewhere under a different name). But it somehow is avoiding many of
    the other compiler issues that I'm seeing when I use gcc.

    I finally gave up and simply copied the structure definitions into my
    own file surrounded by a #ifdef __GNUC__ switch. It compiles now, but
    large sections of my code fails to pass its unit tests (e.g. condition
    variables are not working properly). This same come compiles cleanly
    and runs perfectly under cc. Somehow gcc and AIX are not very
    compatible it seems.

    Have any of you seen this problem?

    Thanks,
    Ravi
    Ravi Desai Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139