delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/07/05:39:31

From: benny AT crocodial DOT de (Benjamin Riefenstahl)
Subject: Re: Linker: Bug or Feature?
7 Nov 1998 05:39:31 -0800 :
Message-ID: <3642E29C.6EAB2372.cygnus.gnu-win32@crocodial.de>
References: <C12566B3 DOT 004AFB18 DOT 00 AT notes DOT kuttig DOT com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Hi Moritz,


mvoss AT kuttig DOT com wrote:
> As a small introduction: I recently started to name my C++ files *.cpp, and
> my C-files *.c. Before, I used the same extension for both.
> 
> ...
>
> The I tried, as a last resort, renaming the .cpp to .c -------and
> magically, IT WORKED!

?? Renaming the file doesn't convert the contents, so I suppose the file
containes plain C code. While C code can be compiled as C++ fine, the
C++ compiler will generate different symbols for import and export, so
that would explain your linker problems. To have the C++ compiler
generate the same symbols as the C compiler, you need to declare the
names with a linkage specification in the code. This looks like this

  extern "C" void asmfunctionfoo( /*parameters*/ );

instead of

  extern void asmfunctionfoo( /*parameters*/ );

like the C code would do it. NB: C doesn't know linkage specifications,
so this change makes your code C++ only.


so long, benny
======================================
Benjamin Riefenstahl (benny AT crocodial DOT de)
Crocodial Communications EntwicklungsGmbH
Ruhrstr. 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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