GLBasic forum

Main forum => Bug Reports => Topic started by: Warwick on 2011-Aug-17

Title: Problem with DIM and REDIM - explicit declarations
Post by: Warwick on 2011-Aug-17
G'day... I'm using version 10.057, and if I have a one-line program that just reads:

DIM a[10]

In a project with 'Explicit declarations' turned on, then I get:

"TestDim.gbas"(1) error : variable is not explicitly defined : a

If I change the program to

LOCAL a
DIM a[10]

Then I get:

C:\Users\Warwick\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\Warwick\AppData\Local\Temp\glbasic\gpc_temp0.cpp:24: error: no matching function for call to `DIM(DGInt&, int)'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:861: note: candidates are: void __GLBASIC__::DIM(__GLBASIC__::DGIntArray&, DGNat, DGNat, DGNat, DGNat)
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:862: note:                 void __GLBASIC__::DIM(__GLBASIC__::DGNatArray&, DGNat, DGNat, DGNat, DGNat)
*** FATAL ERROR - Please post this output in the forum


What do you think is going on here?

Thanks,

Warwick
Title: Re: Problem with DIM and REDIM - explicit declarations
Post by: Crivens on 2011-Aug-17
Code (glbasic) Select
LOCAL a[]
DIM a[10]


Cheers
Title: Re: Problem with DIM and REDIM - explicit declarations
Post by: Warwick on 2011-Aug-17
Thanks for your help with that, and for responding so quickly. It works perfectly now.

I still think it'd be good if GLBasic gave a 'friendlier' error message when someone (like me) gets this wrong.

Cheers,

Warwick
Title: Re: Problem with DIM and REDIM - explicit declarations
Post by: Slydog on 2011-Aug-17
Well, the first error was a friendly error, as it was discovered on the first pass (handled by GLBasic?).

I agree your second error is extremely confusing looking, and almost unhelpful.  But if you notice the error source file names and line numbers (they aren't part of your actual project, "gpc_temp0.cpp:24"), these errors are further along the compilation chain, handled by the C++ compiler which GLBasic has no control over those messages.  At least the error lets you know that the 'DIM' command is having the problem.

[Edit]But it would be nice if GLBasic allowed you to specify the array size when defining an array:   =D
Code (glbasic) Select
LOCAL a[10]