Page 1 of 1
Structure and memory Pointers
Posted: Sun Nov 17, 2024 4:01 pm
by GenRabbit
Why will it not allow this?
Code: Select all
EnableExplicit
Structure Hello
me.i
*you
EndStructure
Define p.hello
p\me = 0
p\*you = AllocateMemory(1000)
FreeMemory(p\*you)
Tried it with you.point, not working either
Re: Structure and memory Pointers
Posted: Sun Nov 17, 2024 4:09 pm
by mk-soft
Pointer inside structures write without
*
Code: Select all
EnableExplicit
Structure Hello
me.i
*you
EndStructure
Define p.hello
p\me = 0
p\you = AllocateMemory(1000)
FreeMemory(p\*you)
Re: Structure and memory Pointers
Posted: Sun Nov 17, 2024 4:32 pm
by GenRabbit
Thanks, in the online manual it says *ptr and ptr is two different variables, yet in structure its is the same...
Re: Structure and memory Pointers
Posted: Sun Nov 17, 2024 6:00 pm
by PBJim
GenRabbit wrote: Sun Nov 17, 2024 4:32 pm
Thanks, in the online manual it says *ptr and ptr is two different variables, yet in structure its is the same...
I remembered seeing something in the manual about this and just checked. In the PDF versions, on page 248 of the shorter version, or 276 of the full version, it mentions that the * is omitted. But yes, you're right, it seems a bit of an exception.
Example: Pointers — from
https://www.purebasic.com/documentation ... cSmall.pdf
Code: Select all
Structure Person
*Next.Person ; Here the ’* ’ is mandatory to declare a pointer
Name$
Age.b
EndStructure
Timo.Person\Name$ = "Timo"
Timo\Age = 25
Fred.Person\Name$ = "Fred"
Fred\Age = 25
Timo\Next = @Fred ; When using the pointer, the ’* ’ is omitted