Coping with underscore decoration conventions

A

AntiPasta

A good day to you all,

I had an old code project lying around, written in C + assembly and
targeted for X86 Linux, that I intended to compile on Win32 as well.
I'm using GCC and NASM on Linux (not really sure which version but
nothing too esoteric), and MingW and NASM on Windows. I quickly ran
into the problem of differing calling conventions between Linux and
Windows: my assembly code exports several symbols, but the MingW GCC
won't link to them unless I prepend a _ to the symbol names, whereas
GCC on Linux seems not to care about this. I guess I can add an
underscore to the required variable names, but I intended to retain
code portability - is there a way around this?
Thanks in advance.
 
K

Kenny McCormack

A good day to you all,

I had an old code project lying around, written in C + assembly and
targeted for X86 Linux, that I intended to compile on Win32 as well.
I'm using GCC and NASM on Linux (not really sure which version but
nothing too esoteric), and MingW and NASM on Windows. I quickly ran
into the problem of differing calling conventions between Linux and
Windows: my assembly code exports several symbols, but the MingW GCC
won't link to them unless I prepend a _ to the symbol names, whereas
GCC on Linux seems not to care about this. I guess I can add an
underscore to the required variable names, but I intended to retain
code portability - is there a way around this?
Thanks in advance.

<OT>
The usual method is to define macros that are turned on in the Winders
compiles.
</OT>
 
A

AntiPasta

<OT>
The usual method is to define macros that are turned on in the Winders
compiles.
</OT>

Well, actually, I'd need to define macros in NASM to do this, but that
is probably impossible in this case. I was looking for a way to get
MingW to "forget" the underscores.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top