flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > (solved) Toggling TCHAR - How both struc and macro? [fasmg]

Author
Thread Post new topic Reply to topic
Beege



Joined: 24 Nov 2018
Posts: 13
Location: USA Indiana
Beege 17 Nov 2019, 20:53
Im using win32a.inc in my code and had single function that needed wide characters so I put together the following macro to toggle TCHAR before the stdcall. This below works but I initially wanted it to be able to check if TCHAR as already wide but couldnt figure out how to do a restore here. I got confused when I found TCHAR was defined as both a struc and a macro. How does the label work in this situation? Any help is appreciated. Thanks!

Code:
macro stdcallw? allargs&
        struc? TCHAR args:?&
                . du args
        end struc
        macro TCHAR args:?&
                du args
        end macro

        stdcall allargs

        struc? TCHAR args:?&
                . db args
        end struc
        macro TCHAR args:?&
                db args
        end macro
end macro

macro invokew?: proc*,args&
        stdcallw [proc],args
end macro    


Last edited by Beege on 17 Nov 2019, 22:23; edited 1 time in total
Post 17 Nov 2019, 20:53
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 Nov 2019, 21:01
For a general answer to your main question see section about symbol classes in the manual.

If the first identifier in the line is a known macro, the second one is not considered. Therefore labeled macro (the one defined with STRUC) is only recognized when it follows a name that is not a known instruction/macro.

As for restoring the macros to their previous state, you should simply use PURGE and RESTRUC (for MACRO and STRUC respectively):
Code:
macro stdcallw? allargs&
        struc? TCHAR args:?&
                . du args
        end struc
        macro TCHAR args:?&
                du args
        end macro

        stdcall allargs

        restruc TCHAR
        purge TCHAR
end macro    
Post 17 Nov 2019, 21:01
View user's profile Send private message Visit poster's website Reply with quote
Beege



Joined: 24 Nov 2018
Posts: 13
Location: USA Indiana
Beege 17 Nov 2019, 22:20
Your awesome Tomasz - Thanks for the help!
Post 17 Nov 2019, 22:20
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 18 Nov 2019, 17:52
Thank you!
Post 18 Nov 2019, 17:52
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.