| 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 |
| X-Authentication-Warning: | lab1-1.eng.utah.edu: tyoung owned process doing -bs |
| Date: | Fri, 2 Mar 2001 16:28:07 -0700 (MST) |
| From: | Trace Young <tyoung AT eng DOT utah DOT edu> |
| To: | cygwin AT sourceware DOT cygnus DOT com |
| Subject: | call c++ from c |
| Message-ID: | <Pine.4.10.10103021617420.29491-100000@lab1-1.eng.utah.edu> |
| MIME-Version: | 1.0 |
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
------------------------------------------------------------
//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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |