Compilator limit: nested blocks too deep

Monkey Targets Forums/Desktop/Compilator limit: nested blocks too deep

Fred(Posted 2012) [#1]
In case it helps someone.

I'm not sure about the english translation of this error.
In french it's:

fatal error C1061: limite du compilateur: blocs imbriqués trop profondément.

It happens when you have too much if elseif elseif ... in your code (more than 128).
Monkey translate Select Case with if elseif. So If you have a (too) huge Case list like my quick and (too much) dirty ressource loader:

Select RessNum
Case 0 BumperBitmap:Image = MyLoadImage( ...
Case 1 ClickSound:Sound = MyLoadSound( ...
...
Case 107 PtrTagada:Tagada = MyLoadTagada( ...
End Select

just add this in the middle of the Select bloc

Select RessNum
...
Case 50 BumperBitmap:Image = MyLoadImage( ...
Case 51 ClickSound:Sound = MyLoadSound( ...

#if TARGET = "glfw"
End Select
Select RessNum
#endif

Case 52 PtrTagada:Tagada = MyLoadTagada( ...
...
End Select

Than the compilator is happy and your code is even more dirty :) but it fixed it. It also means that it might be the time for some refactoring...

But be careful if the Select variable is modified inside some cases, as it can break your code logic