[DONE] 1.877 / 4.30b4: Static array crash

TailBite specific forum

Moderators: gnozal, ABBKlaus, lexvictory

Vladi
User
User
Posts: 33
Joined: Sun Sep 10, 2006 3:09 pm

[DONE] 1.877 / 4.30b4: Static array crash

Post by Vladi »

Any idea about this?

Library:

Code: Select all

ProcedureDLL proc(x)
  Static Dim a(5)
  a(2)=5
   ProcedureReturn x
EndProcedure
This crashes; same result when the static array is declared as global.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Use a global array

Code: Select all

ProcedureDLL MyLib_Init() ; Dim/NewList etc... always in _Init procedure
  Global Dim a(5) 
EndProcedure

ProcedureDLL proc(x) 
  a(2)=5 
  ProcedureReturn x 
EndProcedure
or pseudo static array like this

Code: Select all

Structure ArrayLong5
  l.l[5]
EndStructure 
ProcedureDLL proc(x) 
  Static StaticArray.ArrayLong5
  StaticArray\l[2]=5 
  ProcedureReturn x 
EndProcedure
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Vladi
User
User
Posts: 33
Joined: Sun Sep 10, 2006 3:09 pm

Post by Vladi »

Thanx, it's workin. I understand that I cannot create an array outside a procedure, but why not a static one inside?

The END command also does not seem to work in a library. Is this true?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Vladi wrote:The END command also does not seem to work in a library. Is this true?
The END keyword is only usefull in the main program. Imho it's meaningless in a library.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Vladi
User
User
Posts: 33
Joined: Sun Sep 10, 2006 3:09 pm

Post by Vladi »

For fatal error handling I find it very useful; otherwise you will have to pass it back through the whole module hierarchy, which might not be possible in case of fatal error.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

You can't end a library. A library is never started :wink:
You can only end a program.
This make sense
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Vladi
User
User
Posts: 33
Joined: Sun Sep 10, 2006 3:09 pm

Post by Vladi »

It should not play any role whether a piece of code resides in a previously compiled library or the code actually compiled. As in other languages it makes no difference in which class or *.obj you end the pgm.

With all these restrictions you can never put a portion of a larger system into a library, you always have to recompile the whole bunch.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Thanks, i added a note in the help file.
You can read it online : http://www.tailbite.com/help/Reference/ ... xused.html
Post Reply