www.delorie.com/archives/browse.cgi | search |
From: | Thomas Demmer <demmer AT lstm DOT ruhr-uni-bochum DOT de> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: HELP: Linker hates me! |
Date: | Tue, 05 May 1998 08:57:15 +0200 |
Organization: | Lehrstuhl fuer Stroemungsmechanik |
Lines: | 39 |
Message-ID: | <354EB84B.C911FF38@LSTM.Ruhr-UNI-Bochum.De> |
References: | <354E35F1 DOT 4EE71278 AT sprynet DOT com> <6ilcql$8e3$1 AT news DOT luth DOT se> |
NNTP-Posting-Host: | bvb.lstm.ruhr-uni-bochum.de |
Mime-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Martin Str|mberg wrote: [...] > > Well I don't have any problems with that code: > descartes:/tmp> gcc -Wall main.cc stuff.cc > main.cc:3: warning: return type for `main' changed to integer type > > However this is more interresting: > descartes:/tmp> gcc -Wall main.cc stuff.c > main.cc:3: warning: return type for `main' changed to integer type > /tmp/cca125441.o: In function `main': > /tmp/cca125441.o(.text+0x8): undefined reference to `foo(void)' Well, C++ does name mangling, so int foo(void); is turned into something like _foo_iv by the C++ compiler to enable type safe linking. The C compiler just turns this into _foo. To make your second example work replace the prototype in main by extern "C" { int foo(void); } -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |