[Implemented] Sizeof

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] Sizeof

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

Would it be possible to have sizeof work more like the Blitz Basic 2 Sizeof? You know, you could do:

Code: Select all

Structure foo
  a.w : b.w
EndStructure
; ...
PrintN(Str(Sizeof(foo\b)))
And it would print 2, as it calculates the offset into the structure for the variable. Also, having it evaluated at compile time and usable in your code would be excellent:

Code: Select all

Structure foo
  a.w : b.w
EndStructure
; ...
DataSection
Data.l Sizeof(foo)
EndDataSection

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)