This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linker: Bug or Feature?


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]