flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [solved] How to make struct extendable (fasm1 & fasmg)?

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 08 Jul 2018, 23:10
in windows some structures have extensions that completely repeat fields of previous versions)
for example:
Code:
struct BITMAPV5INFOHEADER
  biSize          dd ?
  biWidth         dd ?
  biHeight        dd ?
  biPlanes        dw ?
  biBitCount      dw ?
  biCompression   dd ?
  biSizeImage     dd ?
  biXPelsPerMeter dd ?
  biYPelsPerMeter dd ?
  biClrUsed       dd ?
  biClrImportant  dd ?
  biRedMask       dd ?
  biGreenMask     dd ?
  biBlueMask      dd ?
  biAlphaMask     dd ?
  biCSType        dd ?
  biEndpoints     CIEXYZTRIPLE
  biGammaRed      dd ?
  biGammaGreen    dd ?
  biGammaBlue     dd ?
  biIntent        dd ?
  biProfileData   dd ?
  biProfileSize   dd ?
  biReserved      dd ?
ends    


Code:
struct BITMAPINFOHEADER ;size 40
  biSize          dd ?
  biWidth         dd ?
  biHeight        dd ?
  biPlanes        dw ?
  biBitCount      dw ?
  biCompression   dd ?
  biSizeImage     dd ?
  biXPelsPerMeter dd ?
  biYPelsPerMeter dd ?
  biClrUsed       dd ?
  biClrImportant  dd ?
ends

struct BITMAPV2INFOHEADER ;size 52
  .               BITMAPINFOHEADER
  biRedMask       dd ?
  biGreenMask     dd ?
  biBlueMask      dd ?
ends

struct BITMAPV3INFOHEADER ;size 56
  .               BITMAPV2INFOHEADER
  biAlphaMask     dd ?
ends

struct BITMAPV4INFOHEADER
  .               BITMAPV3INFOHEADER
  biCSType        dd ?
  biEndpoints     CIEXYZTRIPLE
  biGammaRed      dd ?
  biGammaGreen    dd ?
  biGammaBlue     dd ?
ends

struct BITMAPV5INFOHEADER
  .               BITMAPV4INFOHEADER
  biIntent        dd ?
  biProfileData   dd ?
  biProfileSize   dd ?
  biReserved      dd ?
ends     


disadvantage of such decision - I have to enclose in <> fields of each included previous version when I make data definition
Code:
A BITMAPV2INFOHEADER <0,0,0,0,0,0,0,0,0,0,0>,51,74,35 ; not A BITMAPV2INFOHEADER 0,0,0,0,0,0,0,0,0,0,0,51,74,35    


Is any way to modify structs so they allow descendants from them without <> around of parent?

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 09 Jul 2018, 11:32; edited 1 time in total
Post 08 Jul 2018, 23:10
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 08 Jul 2018, 23:14
The standard "struct" macro already has such feature, see "CPOINT" example in the documentation.
Post 08 Jul 2018, 23:14
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 09 Jul 2018, 05:43
Is struct from fasmgwin support such feature too?
I have to pay for includes size economy with increasing complicity of macros (in case of fasm1 it is built in complicity).

Maybe I shouldn`t economy on lines of struct definitions at all?
I use same includes for fasm1 & fasmg (exept macro definitions itself).
Tomasz, what do thou suggests? thanks.

What if common equates become too big? Is any way to include them all in each project, but with skipping evaluating macros for unused structs etc. in manner of skipping unused procs?
Post 09 Jul 2018, 05:43
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 09 Jul 2018, 08:26
ProMiNick wrote:
Is struct from fasmgwin support such feature too?
It seems to have this implemented, have you tried?

ProMiNick wrote:
What if common equates become too big? Is any way to include them all in each project, but with skipping evaluating macros for unused structs etc. in manner of skipping unused procs?
The best gain could probably be achieved by making headers conditionally include files with structures/equates based on whether they are needed. But the condition might end up being quite complex itself.
Post 09 Jul 2018, 08:26
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 09 Jul 2018, 11:41
Thanks.
I`m glad to know one more feature of both fasms that I missed.
Long time previously I crashed my mind what for child & parent in struct macro. And how it works.
Today all became clear.
Post 09 Jul 2018, 11:41
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.