www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/24/20:50:08.2

Sender: nate AT cartsys DOT com
Message-ID: <36D4948E.F3DAAB07@cartsys.com>
Date: Wed, 24 Feb 1999 16:08:46 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: ASSEMBLER question
References: <13A455A61C0 AT pcc DOT tgm DOT ac DOT at>
Reply-To: djgpp AT delorie DOT com

Carlos Giani_AEN2003 (M2003) wrote:
> 
> Hello everybody. I got the DJGPPASM documentation by Matthew
> Mastracci, and I tried the C++ examples. NASM worked fine. But when I
> try to link my NASM object file with a C program, there appear some
> errors! Does NASM only work with C++ or what??

The problem is most likely with name mangling.  In order to encode type
and other info with a symbol name, G++ changes it to something weird for
the assembly.  However, for C, it leaves it as is, only prepending an
underscore.

So, a C symbol named `foo' would correspond to an ASM symbol named
`_foo', but a C++ symbol named `foo' might correspond to
`_foo__bat342u5ryhy345__' or something equally illegible, depending on
its type.

The best solution is to name all asm-exported symbols in C style, and
declare them with `extern "C"' when using C++.

It would help if you could post an example.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019