[comp.lang.c++] struct name {....} name OK?

ian@dms.cdc.com (Ian Hogg) (10/16/90)

Someone here is porting timed to C++ (actually he is learning C++ and is
porting timed to HP-UX so he's trying to kill two birds with one stone).

Anyways, in /usr/include/netinet/ip_icmp.h we have the following definition

struct icmp {
	      .
	      .
	      . 
	      union {
		      .
		      .
		      .
		      struct ih_idseq {
			n_short icd_id;
			n_short icd_seq;
		      } ih_idseq;
		      int ih_void;
       	     } icmp_hun;
	     .
	     .
	     .
};

In the code we have something like this

  struct icmp icp;

  icp.icmp_hun.ih_idseq.icd_id = something_unimportant;


  This last line generates an error like "union __C9 doesn't have a member
     ih_idseq".

It appears that cfront parses the code without error but generates bad c code.
If we move the definition of struct ih_idseq outside of "struct icmp" and
declare the member ih_idseq as "struct ih_idseq ih_idseq" then everything is
great.

I'm using HP's C++(cfront 2.0)  on HP 9000/3xx.  Is this syntax supposed to be
valid? This code does compile with both Oregon C++ and g++.


-- 
   Ian Hogg	x-4484