Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: RickJ on Sun 17/08/2008 02:10:06

Title: Is this a compiler bug?
Post by: RickJ on Sun 17/08/2008 02:10:06
I want to declare a number of pointer variables.   So normally  I would write somthing like this. 

Button *First;
Button *Prev;
Button *Next;
Button *Last;


This works just fine.  But being the lazy sort I am,  I sometimes will put it all on one line like this. 

Button *First,  *Prev,  *Next,  *Last;


But the compiler throws the following error when it's written that way. 

Failed to save room room0.crm; details below
BluBox.ash(255): Error (line 255): '*' is already defined

--------------------- BluBox.ash -----------------------------------
255: Button *First,  *Prev,  *Next,  *Last;


One other thing I noticed is that when it's written as shown below it apparently works just fine.   There are no compiler errors and I am able to use the Prev, Next, and Last variables as I would any other pointer variable.    It's as if the first"*" is applied to subsequent variables defined on the same line. 

Button *First,  Prev,  Next,  Last;


This doesn't seem to be correct to me.
Title: Re: Is this a compiler bug?
Post by: Shane 'ProgZmax' Stevens on Sun 17/08/2008 03:20:22
It shouldn't really work that way, and I think long single line declarations have been discussed before as confusing the compiler's parser.
Title: Re: Is this a compiler bug?
Post by: RickJ on Sun 17/08/2008 04:24:43
Fair enough, didn't know it was known. ;)
Title: Re: Is this a compiler bug?
Post by: Pumaman on Fri 22/08/2008 20:18:21
Well, it's not consistent with other languages like C, but really my plan would be to scrap the * altogether, since there's really no need for it with the "managed" designation for pointer structs.