Ask a Question related to AIX, Design and Development.
-
Ravi Desai #1
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
-
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... -
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... -
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... -
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... -
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... -
Jeff Trawick #2
Re: Differences is using netdb.h with the cc and gcc compilers.
Ravi Desai wrote:
gcc uses its own copy of some system header files. Maybe your gcc> 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).
installation is using its own netdb.h?
Jeff Trawick Guest
-
Ravi Desai #3
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 >...
Thanks for the reply - I've searched (the entire system, actually) for> 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?
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



Reply With Quote

