robert@sri-spam.istc.sri.com (Robert Allen) (04/27/88)
Welcome back for another installment of: port that code!
When last we left our intrepid hero he was trying to port
the gated program from a Vax/Sun BSD environment to the
HP9000/300 "BSD" environment. Our brave programmer was
having difficulty with a particular header file which gated
needed to compile, /usr/include/net/if.h. At great
personal risk to life and sanity our hero obtained said
header file, placed it in the gated src directory, and
compiled. We return thusly to our story...
The compile failed with a message from the compiler;
"ext.c", line 113: redeclaration of ifnet
The 'ifnet' in question is a variable declared in ext.c
as "struct interface *ifnet". Within a gated src header
file (defs.h) are all of the extern declarations for gateds'
global variables, including "extern struct interface *ifnet".
After due examination, I found that /usr/include/net/if.h
also has a variable name ifnet, "extern struct ifnet *ifnet".
As you will notice the two extern declarations are of differnt
types, thus causing the redeclaration compile time error above.
I am using the if.h file from an HP 9000/800. I've compared it
to the corresponding file from the Sun computer, and found there
is a difference between the two files' use of the 'ifnet' variable.
On the Sun if.h it is thus:
#ifdef KERNEL
#ifdef INET
struct ifqueue ipintrq;
#endif
struct ifnet *ifnet;
...
....
.....
#endif
On the HP if.h it is thus:
extern struct ifnet *ifnet; /* No ifdefs here folks... */
I'm wondering if anyone else has encountered this problem, with either
the ifnet name or other names. If indeed the *ifnet variable is allocated
somewhere in the header files then should it not be ifdef'ed out when the
file isn't being used in the kernel? More specifically, if the variable
is for the kernel only both it and its' extern declaration should be
'hidden' from us applications programmers. I would like to know if
this is a bug or a feature. If it is a bug, is there any plan to fix
it? If it is a feature, what is it used for? Since gated uses many
network'esque variable names it is probable that I may encounter other
problems with namespace overlaps. I really need a solution other than
re-writing gated, particularly since this problem doesn't seem to occur
on either Suns or VAXen.
I would appreciate answers from anyone who has experienced this problem,
as well as from anyone in-the-know at HP. This is bad for me...
--
----------------------------------------------------------------
Robert Allen, robert@spam.istc.sri.com
415-859-2143 (work phone, days)
----------------------------------------------------------------