Subject: Re: port-alpha/5586: port alpha does not define "unix"
To: Greg A. Woods <woods@weird.com>
From: Andrew Brown <twofsonet@graffiti.com>
List: netbsd-bugs
Date: 06/16/1998 16:50:31
>I have, over the years, suffered dramatically from namespace pollution 
>issues. Someone innocently defines a structure in 4.3 BSD that
>uses the name "sun" (thinking "s un") and the code mysteriously fails
>for no good reason when compiled on my Sun, requiring large amounts of 
>work to figure out what the hell is going on. Similar stuff has bit me 
>over and over. I don't care if ancient practice was to define lots of
>convenient preprocessor variables. The gods of portability spoke a
>while back, and they made a reasonably good decision. Other unices
>like Solaris have gone this route -- no reason we shouldn't follow.

actually...my current, least favorite solarisism is their completely
fouled up struct in_addr.

to quote /usr/include/netinet/in.h (from solaris 2.5.1)

   /*
    * Internet address
    *      This definition contains obsolete fields for compatibility
    *      with SunOS 3.x and 4.2bsd.  The presence of subnets renders
    *      divisions into fixed fields misleading at best.  New code
    *      should use only the s_addr field.
    */
   struct in_addr {
	   union {
		   struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b;
		   struct { u_short s_w1, s_w2; } S_un_w;
		   u_long S_addr;
	   } S_un;
   #define s_addr  S_un.S_addr             /* should be used for all code */
   #define s_host  S_un.S_un_b.s_b2        /* OBSOLETE: host on imp */
   #define s_net   S_un.S_un_b.s_b1        /* OBSOLETE: network */
   #define s_imp   S_un.S_un_w.s_w2        /* OBSOLETE: imp */
   #define s_impno S_un.S_un_b.s_b4        /* OBSOLETE: imp # */
   #define s_lh    S_un.S_un_b.s_b3        /* OBSOLETE: logical host */
   };

probably you can, but i can't recall ever seeing any code that ever
used any of these fields.  and it caused me no end of headaches when a
source package i was compiling had a local "int s_net" declared in
almost every function.  stick that in your preprocessor and compile
it.

after finally figuring exactly where the detritus was coming from
(sun's header file) and discovering that a simple fix was not so
simple (edit every source file?) i gave up and hacked netinet/in.h to
be less insolent (i'll never use those defines anyway).

so...define what you will.  or won't.  someone somewhere will hate you
for it.  or not.  you can't win.  or lose.  or break even.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
warfare@graffiti.com      * "information is power -- share the wealth."