RFC: bbox 1.5.0?

Denis Vlasenko vda.linux at googlemail.com
Mon Mar 19 21:45:54 UTC 2007


On Monday 19 March 2007 18:07, Natanael Copa wrote:
> > I vote for sed -i -e s/gnu99/c99/ Makefile.flags
> > for a couple of days and fix those for a start.. :-/
> 
> Shouldn't be too hard. Just some brute force work.
> 
> First hit:
> include/libbb.h:299: warning: declaration does not declare anything
> 
> Code:
> typedef struct len_and_sockaddr {
>         socklen_t len;
>         union {
>                 struct sockaddr sa;
>                 struct sockaddr_in sin;
> #if ENABLE_FEATURE_IPV6
>                 struct sockaddr_in6 sin6;
> #endif
>         };
> } len_and_sockaddr;
> 
> The problem is that c99 don't allow anonymous unions. Could be fixed
> with:
> 
> --- include/libbb.h     (revision 18165)
> +++ include/libbb.h     (working copy)
> @@ -296,7 +296,7 @@
>  #if ENABLE_FEATURE_IPV6
>                 struct sockaddr_in6 sin6;
>  #endif
> -       };
> +       } u;
>  } len_and_sockaddr;
>  /* Create stream socket, and allocated suitable lsa
>   * (lsa of correct size and lsa->sa.sa_family (AF_INET/AF_INET6)) */
> 
> but then we need to 's/->sa\./->u.sa./g; s/->sin\./->u.sin./g' lots of
> places. Do we want that?
> 
> How should we handle anonymous unions properly?

I'm sorry, but I'm not very happy with this. Anonymous structs
and unions can be handy in many cases. Why obfuscate code with
those var.u.sa, var.u.sa6 - in the name of compatibility with C99?
But virtually everybody uses gcc and also I won't be surprised
if newer C standard will allow anon unions anyway.

I even contemplated allowing declarations in the middle of
the block (C++ style), but I guess this would upset a lot of
C lovers. ;) So I won't do it...
--
vda



More information about the busybox mailing list