This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Linker: Bug or Feature?
- To: gnu-win32 at cygnus dot com
- Subject: Re: Linker: Bug or Feature?
- From: Benjamin Riefenstahl <benny at crocodial dot de>
- Date: Fri, 06 Nov 1998 12:50:52 +0100
- Organization: Crocodial Communications EntwicklungsGmbH
- References: <C12566B3.004AFB18.00@notes.kuttig.com>
Hi Moritz,
mvoss@kuttig.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@crocodial.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@cygnus.com" with one line of text: "help".