home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!wupost!sdd.hp.com!news.cs.indiana.edu!nstn.ns.ca!cs.dal.ca!ug.cs.dal.ca!johnston
- From: johnston@ug.cs.dal.ca (geoff)
- Subject: Calling C++ functions from C
- Message-ID: <C0K1v0.HGw@cs.dal.ca>
- Sender: usenet@cs.dal.ca (USENET News)
- Nntp-Posting-Host: ug.cs.dal.ca
- Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada
- Date: Fri, 8 Jan 1993 21:47:24 GMT
- Lines: 21
-
-
- I have run into a problem calling C++ functions from C.
- Currently I am using the 'extern "C"' method to avoid mangling
- the C++ function which is to be included in a library to be called by
- a C program.
-
- So what I am doing now (which fails at run-time with a bus error)
- is:
- compile the C++ function into an object file
- create an archive library with 'ar' from that object file
- compile the calling C program with both the above library and libC.a
-
- I have been able to easily call C from C++ and C++ from C++
- using this kind of approach. But this runtime error puzzles me.
-
- Advice from anyone who has worked with calling C++ from C would
- be appreciated (unix). I profusely apologize for any editing
- screwups / other assorted infractions: I'm on a *very* slow telnet link.
-
- -Geoff Johnston
-
-