From: Roman Mashak on
Hello, All!

I supposed that PF_* and AF_* declarations are identical, at least according
to bits/socket.h. So why I can't use this piece of code:

struct sockaddr_in s_in;
int sd; /* socket descriptor */
struct ifreq ifr;

if ( sd = socket(PF_INET, SOCK_RAW, 0) < 0 ) {
perror("socket() error!");
exit(1);
}

bzero(&s_in, sizeof(s_in));
s_in.sin_family = AF_INET;

if ( bind(sd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) {
perror("bind() error!");
exit(1);
}

.....

close(sd);

I receive error: storage size of `ifr' isn't known.
gcc -ansi -o skt skt.c

Without '-ansi' flag everything is fine. What is the point?

With best regards, Roman Mashak. E-mail: mrv(a)tusur.ru


From: Rainer Temme on
Hi Roman,

since your example doesn't shows just a snippet of code
rather than something that really compiles my
assumption is the following:

Your problem is not realated to AF_INET or PF_INET ...
Your problem is that your not including the correct headerfile
that defines the ifreq-struct.
May be in non-ansi mode this is ignored because you
never make use of the variable ifr.
As well quite likely in ansi-mode the compiler complains
about this.

Regards ... Rainer


From: Villy Kruse on
On Wed, 22 Jun 2005 22:05:08 +0900,
Roman Mashak <mrv(a)tusur.ru> wrote:


>
> I receive error: storage size of `ifr' isn't known.
> gcc -ansi -o skt skt.c
>
> Without '-ansi' flag everything is fine. What is the point?
>

You only use -ansi if you don't use any extension such as sockets
or other POSIX defined functions.


Villy