Pointers to structs / Problems ?
Posted: Sat Aug 28, 2004 5:27 pm
Hi all,
I'm unsure whether this is a bug with pb or just me doing something stupid...I'm returning the address of a structure from a procedure. A couple issues arise.
With the debugger on, I seem to be getting garbage values within its member fields. With it off, things seem to be okay... ( on another note, the debugger wont work with #PB_Any either soo I'm guessing the debugger needs some debugging
? )
Now, even with the debugger off, I can usually only read 1 value from the structure. Everything after returns garbage.
Heres the test code I was using in an attempt to figure out whats going on:
The first value (in this case, *SomeDude\Name) is right-- everything after goes to hell.
Its like the pointer is dying or moving somehow (?!?). Am I doing something wrong here?
I'm unsure whether this is a bug with pb or just me doing something stupid...I'm returning the address of a structure from a procedure. A couple issues arise.
With the debugger on, I seem to be getting garbage values within its member fields. With it off, things seem to be okay... ( on another note, the debugger wont work with #PB_Any either soo I'm guessing the debugger needs some debugging

Now, even with the debugger off, I can usually only read 1 value from the structure. Everything after returns garbage.
Heres the test code I was using in an attempt to figure out whats going on:
Code: Select all
Structure Person
Age.l
Name.s
EndStructure
Procedure.l NewPerson(Name.s,Age.l)
Protected This.Person
This\Name=Name
This\Age=Age
ProcedureReturn @This.Person
EndProcedure
Procedure Test(*This.Person)
MessageRequester("Testing..",*This\Name, #PB_MessageRequester_Ok)
EndProcedure
;================================================
OpenConsole()
*SomeDude.Person = NewPerson("Bob",26)
PrintN(*SomeDude\Name)
PrintN(Str(*SomeDude\Age))
PrintN(*SomeDude\Name)
PrintN(Str(*SomeDude\Age))
;Test(SomeDude.Person)
;Test(SomeDude.Person)
Input()
Its like the pointer is dying or moving somehow (?!?). Am I doing something wrong here?