|
Post by Emil_halim on Apr 17, 2018 17:26:47 GMT 1
Hi all
This code print 16 and give wrong size of type , it must be 14
Type BITMAPFILEHEADER bfType As Int16 bfSize As Long bfReserved1 As Int16 bfReserved2 As Int16 bfOffBits As Long End Type
print SizeOf(BITMAPFILEHEADER)
Do Sleep Until Me Is Nothing
|
|
|
Post by scalion on Apr 17, 2018 20:20:09 GMT 1
Hi, Effectively, It's just a question of speed, but hello the size of the table in memory!
In fact this appears in the documentation:
"Dieser Type würde also 14 Bytes belegen (1 + 4 + 1 + 8), wenn nicht Speicherzugriffe auf unausgerichtete Daten im Speicher auch auf INTEL-Prozessoren benachteiligt sind (auf anderen Prozessoren (MIPS, Alpha, M68000) sogar noch erheblich mehr). Deshalb werden vom GFA-BASIC 32 automatisch Füllbytes eingefügt, um eine Ausrichtung auf entsprechende Byte-Grenzen zu erreichen."
Therefore, GFA-BASIC 32 automatically inserts padding bytes to match byte boundaries.
To have an exact size of corresponding data you must use Packed Statement :
Type BITMAPFILEHEADER Packed 1 bfType As Int16 bfSize As Long bfReserved1 As Int16 bfReserved2 As Int16 bfOffBits As Long End Type
print SizeOf(BITMAPFILEHEADER) // <- Give 14
Do Sleep Until Me Is Nothing
|
|
|
Post by Emil_halim on Apr 17, 2018 21:03:37 GMT 1
great , yah..
thank a lot
i will update my last demo with your solution.
|
|