home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18867 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.2 KB  |  33 lines

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