Code: Select all
x.l = $AABBCCDD
y.l
! unsigned short *p_p;
! p_p = &v_x ;
! v_y = *p_p;
Debug Hex(y)
! unsigned short *p_p2;
! p_p2 = (&v_x + 1);
! v_y = *p_p2;
Debug Hex(y)
Code: Select all
x.l = $AABBCCDD
y.l
! unsigned short *p_p;
! p_p = &v_x ;
! v_y = *p_p;
Debug Hex(y)
! unsigned short *p_p2;
! p_p2 = (&v_x + 1);
! v_y = *p_p2;
Debug Hex(y)
Code: Select all
x.l = $AABBCCDD
y.l
!typedef struct uint16 {
!unsigned short uint;
!} uint16;
! uint16 *p_p1 = (void*)((integer)(&v_x));
! v_y = p_p1->uint;
Debug Hex(y)
! uint16 *p_p2 = (void*)(((integer)(&v_x))+2);
! v_y = p_p2->uint;
Debug Hex(y)
Code: Select all
;... like this not working example
*ptr.unicode = @x
! v_y = p_ptr->u;
Debug Hex(y)
Unfortunately, pointers in Purebasic do not have type.
Of course, pointers in PureBasic can have a structure type.useful wrote: Wed Oct 16, 2024 9:26 amUnfortunately, pointers in Purebasic do not have type.
They are always void
Therefore, additional effort is needed in the form of functions: peek[type], poke[type]
https://www.purebasic.com/documentation ... index.html
p.s. Sometimes purebasic behaves like basic.![]()
Code: Select all
Define x.s = "01234"
Define y
Define *ptr.unicode = @x
;y = *ptr\u
! v_y = p_ptr->f_u;
Debug Hex(y)
But I will hope that instead of the non-obvious way of typing through single-element structures, we will get just the pointer type and, as a result, pointer arithmetic.mk-soft wrote: Wed Oct 16, 2024 9:56 amOf course, pointers in PureBasic can have a structure type.useful wrote: Wed Oct 16, 2024 9:26 amUnfortunately, pointers in Purebasic do not have type.
They are always void
Therefore, additional effort is needed in the form of functions: peek[type], poke[type]
https://www.purebasic.com/documentation ... index.html
p.s. Sometimes purebasic behaves like basic.![]()
For simple types, these are predefined in PB. *ptr.integer, long, word, unicode, etc.
The access is also easier and faster than with the function calls of Peek and Poke.
Code: Select all
Define x.s = "01234" Define y Define *ptr.unicode = @x ;y = *ptr\u ! v_y = p_ptr->f_u; Debug Hex(y)
Code: Select all
x.l = $AABBCCDD
y.l
! unsigned short *p_p;
! p_p = &v_x ;
! v_y = *p_p;
Debug Hex(y) ;CCDD
! unsigned short *p_p2;
! p_p2 = (integer)(&v_x) + 1;
! v_y = *p_p2;
Debug Hex(y) ;BBCC
! p_p2 = (integer)(p_p2) + 1;
! v_y = *p_p2;
Debug Hex(y) ;AABB
! p_p2 = (integer)(&v_x) + 2;
! v_y = *p_p2;
Debug Hex(y) ;AABB
! p_p2 = &v_x;
! p_p2 += 1;
! v_y = *p_p2;
Debug Hex(y) ;AABB