delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT sources DOT redhat DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT sources DOT redhat DOT com> |
List-Help: | <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT sources DOT redhat DOT com |
Delivered-To: | mailing list cygwin AT sources DOT redhat DOT com |
Message-ID: | <3AA36BED.4E6DB8AF@ism.tu-berlin.de> |
Date: | Mon, 05 Mar 2001 10:35:25 +0000 |
From: | Georg Fusz <fusz AT ism DOT tu-berlin DOT de> |
Organization: | Techn.University Berlin |
X-Mailer: | Mozilla 4.76 [en] (WinNT; U) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
To: | Trace Young <tyoung AT eng DOT utah DOT edu> |
CC: | cygwin AT sourceware DOT cygnus DOT com |
Subject: | Re: call c++ from c |
References: | <Pine DOT 4 DOT 10 DOT 10103021617420 DOT 29491-100000 AT lab1-1 DOT eng DOT utah DOT edu> |
--------------F7EC0C52F531821D87DD33AF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Trace Young wrote: > > Hi, is anybody could help me to point out the problem: > > my problems is: it could not link while calling a c++ function in > cpp file from c function in c file with the main(). > > both c and cpp files can be compiler in VC++ in NT4.0, but not link > the link error message is "unresolved external symbol _cpp_function". > ( but I could do those in GUN g++ in Uuix ) > > following is my code > ------------------------------------------------------------------ > /*c_file.c*/ > #include "c_file.h" > int main(){ > cpp_function(); > return(0); > } > > ---------------------------------------------------------- > > /*c_file.h*/ > #ifndef __cplusplus > extern "C++" { > #endif > > #include "cpp_file.h" > > #ifndef __cplusplus > } > #endif > > Here is your mistake !!!!!!!!!!!!!!!!!!!!! #ifdef __cplusplus extern "C" { #endif void cpp_function( void ); #ifdef __cplusplus } #endif ------------------------------------------------------------ > > //cpp_file.cpp > #include "cpp_file.h" > #include <iostream> > /* > foo::foo() { > i=0; > } > */ > void cpp_function(){ > foo f; > > f.see(); > cout<<"Hi, I am in Cpp file and called by C file\n"<<flush; > } > > --------------------------------------------------------------------- > > //cpp_file.h > #include <iostream.h> > > class foo { > public: > int i; > > foo() {i=0; } > ~foo() {} > > void see() { > cout << "--------------I am inside class ------------" << endl; > } > > }; > > void cpp_function(); > ------------------------------------------------------------------------------------ > > Thank for any help. > > Trace > > -- > Want to unsubscribe from this list? > Check out: http://cygwin.com/ml/#unsubscribe-simple -- Georg Fusz Technische Universitaet Berlin, Germany Fon: Uni.: +49 30 314 26 884 privat: +49 30 815 30 32 Handy: +49 173 20 10 696 Homepage: http://www.cadlab.tu-berlin.de/~fusz/ --------------F7EC0C52F531821D87DD33AF Content-Type: application/x-zip; name="mixed.zip" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="mixed.zip" UEsDBBQAAAAIAHpSZSrff0oswAAAACABAAAGAAAAZm9vLmNjlY7NigIxEITvgbxDMXpQcCeJ 4mUMexFB32FBYn6YQEyCMxHdxXdfM7c9bp+Kr7u6ijHMT6aDS6nVenWHaAXWnAvGN4xvIXgn Np3YwpXhG4dHxpwSSmY+6lCMRdNbZeztrHXbN3820qdhvFl1/az4nryBzvnsStSjT3GBCS0p +aEENR9uVy8Bxj7+PdU3/WkHaxfLXdU6lVHK5uhXOEFd4SP2OcP5YKHiu44KwRpcnthP8Cs2 UrpQhv5tf9UulPwCUEsDBBQAAAAIALJTZSp5XyNthAAAAKwAAAAKAAAAaGVhZGVyX2MuaG2M vQrCMBhF90De4VI7KEjzJdIljuLgUwTJDw1IGtqmFMV3t3Vy8MJZLocjBOqb0+j83fnB2KY7 zpCNgiKSgk6CWkjSijQphDI+cV0yas4428XgfIAxNj/KuMGZXyY/JFSXCq/V8MnFsLlzHx1s ziaUZKfYpz2+1+HMGdb9r71/E5x9AFBLAwQUAAAACACJUmUqvbtFhIMAAACcAAAABgAAAG1h aW4uY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AAAsA AAAAAAAAAQAhACSBHQMAAGhlYWRlcl9jYy5oUEsFBgAAAAAFAAUADwEAAOYDAAAAAA== --------------F7EC0C52F531821D87DD33AF Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple --------------F7EC0C52F531821D87DD33AF--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |