Subject: Re: Linker: Bug or Feature?
From: [email-masked] (Benjamin Riefenstahl)

7 Nov 1998 05:39:31 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

Hi Moritz,

[email-masked] 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 ([email-masked])
Crocodial Communications EntwicklungsGmbH
Ruhrstr. 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".