I take advantage of these posts to recall certain characteristics of an 'Any Ptr'.
The 'Any Ptr' is a special pointer type that allows pointing to any variable type:
- Since all typed pointers have a size of 4|8 bytes (for 32|64 bit compiling), 'Sizeof(Any Ptr) = 4|8'.
- Pointer arithmetic depends of the variable type pointed to. When adding for example '+1' to a typed pointer, the resulting pointer value (address) is incremented by the size of the variable type pointed to.
Pointer arithmetic is also allowed on an 'Any Ptr', but it is treated (by convention) like a Byte|UByte Ptr (when adding '+1' to an 'Any Ptr', the resulting pointer value is incremented by 1).
- For an 'Any Ptr Ptr', the pointer arithmetic depends of the variable type pointed to (an 'Any Ptr' in this case). Therefore when adding '+1' to an 'Any Ptr Ptr', the resulting pointer value is incremented by the size of the 'Any Ptr' type, ie 4|8.
Example:
Code: Select all
Print "'Short Ptr' incremented by '+1':"
Dim As Short Ptr ps = 0
Print ps
ps += 1
Print ps
Print
Print "'Any Ptr' incremented by '+1':"
Dim As Any Ptr pa = 0
Print pa
pa += 1
Print pa
Print
Print "'Any Ptr Ptr' incremented by '+1':"
Dim As Any Ptr Ptr ppa = 0
Print ppa
ppa += 1
Print ppa
Sleep