Author Topic: Making a macro public  (Read 162 times)

kiptron

  • Regular Member
  • *
  • Posts: 26
Making a macro public
« 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

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7820
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Making a macro public
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

HSE

  • Member
  • *****
  • Posts: 1464
  • <AMD>< 7-32>
Re: Making a macro public
« Reply #2 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.

kiptron

  • Regular Member
  • *
  • Posts: 26
Re: Making a macro public
« Reply #3 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

Vortex

  • Member
  • *****
  • Posts: 2460
Re: Making a macro public
« Reply #4 on: November 21, 2020, 07:59:32 PM »
Hi kiptron,

Quote
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.

If you are using Masm64, you don't need full prototypes. Does your macro declare the API functions with the statement EXTERNDEF?

kiptron

  • Regular Member
  • *
  • Posts: 26
Re: Making a macro public
« Reply #5 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

Vortex

  • Member
  • *****
  • Posts: 2460
Re: Making a macro public
« Reply #6 on: November 22, 2020, 06:38:29 AM »
Hi kiptron,

Here is a quick example for you :

Code: [Select]
@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.

kiptron

  • Regular Member
  • *
  • Posts: 26
Re: Making a macro public
« Reply #7 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