Is this a compiler bug?

Started by RickJ, Sun 17/08/2008 02:10:06

Previous topic - Next topic

RickJ

I want to declare a number of pointer variables.   So normally  I would write somthing like this. 
Code: ags

	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. 
Code: ags

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


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

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. 
Code: ags

	Button 	*First,  Prev,  Next,  Last;


This doesn't seem to be correct to me.

Shane 'ProgZmax' Stevens

It shouldn't really work that way, and I think long single line declarations have been discussed before as confusing the compiler's parser.

RickJ

Fair enough, didn't know it was known. ;)

Pumaman

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.

SMF spam blocked by CleanTalk