The MASM Forum

General => The Campus => Topic started by: kiptron on November 21, 2020, 09:08:46 AM

Title: Making a macro public
Post by: kiptron on November 21, 2020, 09:08:46 AM
Hey folks,  just a quick question. How do I make a macro public in my
Include file ?? It is not a proc or a variable so EXTERNDEF doesn't seem
to work.  Thanks and Happy Thanksgiving  !!  Kiptron
Title: Re: Making a macro public
Post by: hutch-- on November 21, 2020, 09:15:47 AM
PUBLIC is done in binary where a macro is run before assembly. I think what you need is the IFNDEF notation that if the macro is not defined, it gets defined conditionally.
Title: Re: Making a macro public
Post by: HSE on November 21, 2020, 10:13:07 AM
Kiptron:

You can write the macros in a file, and include the same file in every module.
Title: Re: Making a macro public
Post by: kiptron on November 21, 2020, 01:23:53 PM
That makes sense,  I will try that. Thank you HSE  I should have thought of that. I am
fairly experienced at this. I wrote two nifty little macros to adjust and restore the stack
and creating the 32 byte "shadow space" before and after making an un-prototyped
API call. That is the issue that has given me huge problems with running many of the
"extension" calls of Opengl. Thanks again    Kiptron
Title: Re: Making a macro public
Post by: Vortex on November 21, 2020, 07:59:32 PM
Hi kiptron,

QuoteI wrote two nifty little macros to adjust and restore the stack
and creating the 32 byte "shadow space" before and after making an un-prototyped
API call.

If you are using Masm64, you don't need full prototypes. Does your macro declare the API functions with the statement EXTERNDEF?
Title: Re: Making a macro public
Post by: kiptron on November 22, 2020, 05:28:25 AM
  So far I am just trying to share a macro(make it visible across .asm files) just like you would
do with any proc or variable,   like   externdef whatever_variable: dword  or externdef whatever_proc:near
but that won't work with macros. A macro has no type.  I can't say externdef whatever_macro: ?????  What's the type ??
It has no type. HSE recommended putting macros in an include file but if you think about it that won't
work either.  Scratching my head. Happy Thankgiving   Kiptron
Title: Re: Making a macro public
Post by: Vortex on November 22, 2020, 06:38:29 AM
Hi kiptron,

Here is a quick example for you :

@sum MACRO x,y

    mov     eax,x
    add     eax,y
    EXITM   <eax>

ENDM


The @sum macro is called twice by the Main and TestFunc modules. This macro's definion can be found in the include file named MyMacro.inc
You can examine the modules in the attachment.
Title: Re: Making a macro public
Post by: kiptron on November 22, 2020, 09:20:01 AM
Thank you Vortex, Yes I see, you just put the text of the macro in
the .inc file. I made a total error. My macro used an undefined variable.
                                   OOPS  Kiptron