flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Expand macro for two public names

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 226
alorent 07 Feb 2026, 09:29
Hi,

In my .asm file and can compile it for x86 and x64 (well, I use "use32" and "use64" in the code)

Anyway, it looks like the linker in MSVC for x64 object expects the public name with "_" prefix in the name, something like:

Code:
public MyName as '_MyName'    


but for x64 the underscore is not appended, sot the MSVC linker expects it like

Code:
public MyName as 'MyName'    


So I try to build a macro to avoid putting in every file something like:

Code:
public MyName as '_MyName'
public MyName as 'MyName'
    


And put something like:

Code:
PUBLIC_ARCH MyName    


which it should be expanded as the two above public lines. I have created this macro:

(Well, the macro also adds a "suffix" like "_x86" and "_x64" but that's another story)

Code:
macro PUBLIC_ARCH name, suffix
{
  local s1, s2
  s1 equ '_#name#suffix'
  s2 equ  '#name#suffix'
  public name as s1
  public name as s2
}
    


But the linker finally complains with:

Code:
warning LNK4006: `_#name#suffix already defined in xxxxx.obj;
warning LNK4006: `#name#suffix already defined in xxxxx.obj;
warning LNK4006: `_#name#suffix already defined in xxxxx.obj;
warning LNK4006: `#name#suffix already defined in xxxxx.obj;
warning LNK4006: `_#name#suffix already defined in xxxxx.obj;
warning LNK4006: `#name#suffix already defined in xxxxx.obj;
warning LNK4006: `_#name#suffix already defined in xxxxx.obj;
warning LNK4006: `#name#suffix already defined in xxxxx.obj;
...
...
...
    


So it looks my macro is just expanding to;

Code:
public MyName as '_#name#suffix '
public MyName as '#name#suffix '
    


I have tried different approaches but no luck Sad

Any help?

Thanks!
Post 07 Feb 2026, 09:29
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4367
Location: vpcmpistri
bitRAKE 07 Feb 2026, 10:21
This works if they aren't already quoted strings?
Code:
macro PUBLIC_ARCH name, suffix
{
  match , suffix
  \{
    public name as '_'#`name
    public name as      `name
  \}
  match any, suffix
  \{
    public name as '_'#`name#`suffix
    public name as      `name#`suffix
  \}
}    
Post 07 Feb 2026, 10:21
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20868
Location: In your JS exploiting you and your system
revolution 07 Feb 2026, 13:19
bitRAKE wrote:
Code:
macro PUBLIC_ARCH name, suffix
{
  match , suffix
  \{
    public name as '_'#`name
    public name as      `name
  \}
  match any, suffix
  \{
    public name as '_'#`name#`suffix
    public name as      `name#`suffix
  \}
}    
That can be simplified to:
Code:
macro PUBLIC_ARCH name, suffix='' {
    public name as '_'#`name#`suffix
    public name as     `name#`suffix
}    
Post 07 Feb 2026, 13:19
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 226
alorent 07 Feb 2026, 15:24
Thanks a lot bitRAKE and revolution!!! Smile
Post 07 Feb 2026, 15:24
View user's profile Send private message 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-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.