Global Initializers Must Be Constant?

BlitzMax Forums/BlitzMax Beginners Area/Global Initializers Must Be Constant?

Gabriel(Posted 2005) [#1]
EDIT: Don't worry about it. I just ripped out a huge section of code and rewrote it rather than spend hours trying to figure out why the debugger was reporting an error at least 5,000 lines away from the actual problem code.


Curtastic(Posted 2005) [#2]
I HATE THAT

It is caused by putting a global array in a type, which apparently isn't allowed


Dreamora(Posted 2005) [#3]
it isn't a problem
You just can't do
type
   global something:type = type.create ()

end type

or similar

but you can simply add a

type
   global something:type

   method new ()
      if something = null something = type.create ()
   end method
end type


as it is normal in OO (aka initialize stuff in constructor)


Curtastic(Posted 2005) [#4]
hey, heres the problem
Type guy
	Field name:String
	Global array[99]
EndType




Function hi()
	Print "hi"
EndFunction


















































Function DontPickOnMe()
EndFunction



Koriolis(Posted 2005) [#5]
http://blitzbasic.com/Community/posts.php?topic=48801#542955


Gabriel(Posted 2005) [#6]
Aha, well then yes, I think I did make this "mistake" in my old code. When I rewrote it, I evidently didn't repeat myself, because it's fine now. I agree that it should be possible and Mark's proposed solution, doing it before anything else, works for me.