D 2.x conversion problems

Dan murpsoft at hotmail.com
Sat Dec 8 22:27:36 PST 2007


Dan Wrote:

> Bill Baxter Wrote:
> Dan Wrote:
> > > Error: 'b' is not a member of 'const(Value)'
> > > 
> > > --- errorlevel 1
> > Shot in the dark here, but it reminds me of error messages I've seen 
> > from using named unions.
> > 
> > Somewhere in the past you used to be able to say
> > struct Value
> > {
> >     union b{
> >        int i;
> >        long l;
> >     }
> > }
> > 
> > Value x;
> > x.b.i; // was ok at some point in the past
> > 
> > But that became an error.  And I believe the error message was something 
> > like "b is not a member of Value".  The fix is to do something like:
> > 
> > struct Value {
> >     union _b {
> >        int i;
> >        long l;
> >     }
> >     _b b;
> > }
> > 
> > Sorry if this is wrong and leads you down the wrong path!  But you're 
> > not giving us a lot to go on.  :-)
> 
> No, that's quite informative.  The error I was given was not alot to go on either.  I was pretty shocked it didn't even give me a line number or even a specific file that needed changing.
> 
> Now I know I'm probably looking for a named union type.  Does it matter that I have about six dozen "anonymous" unions inside my structs?

Sorry, I should have provided the code I think it might be.  I honestly don't seen anything wrong with it, because it worked on 1.05 (which I now can't download and run because it doesn't work)

[code]
struct Value {
	union {		
		struct {
			uint length;
			char[]* keys;
			Value* values;
		}
		struct {
			union {
				Value[] sf;
				Value function(inout Value self,inout Value cc,Value[] arguments ...) nf;
			}
			ubyte arity;
		}
		Value[] a;
		char[] s;
		bool b;
		int i;
		double d;
		d_time dt;
	}
struct Value {
	union {		
		struct {
			uint length;
			char[]* keys;
			Value* values;
		}
		struct {
			union {
				Value[] sf;
				Value function(inout Value self,inout Value cc,Value[] arguments ...) nf;
			}
			ubyte arity;
		}
		Value[] a;
		char[] s;
		bool b;
		int i;
		double d;
		d_time dt;
	}
struct Value {
	union {		
		struct {
			uint length;
			char[]* keys;
			Value* values;
		}
		struct {
			union {
				Value[] sf;
				Value function(inout Value self,inout Value cc,Value[] arguments ...) nf;
			}
			ubyte arity;
		}
		Value[] a;
		char[] s;
		bool b;
		int i;
		double d;
		d_time dt;
	}
...
[/code]


More information about the Digitalmars-d-learn mailing list