home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18218 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.0 KB  |  23 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.aero.org!speedy.aero.org!deveel.aero.org!swed
  3. From: swed@deveel.aero.org (Greg Swedberg)
  4. Subject: Re: How to call C++ functions in a C program?
  5. Message-ID: <1992Dec18.233948.3538@speedy.aero.org>
  6. Sender: news@speedy.aero.org
  7. Nntp-Posting-Host: deveel.aero.org
  8. Organization: The Aerospace Corporation; El Segundo, CA
  9. References: <1gqbepINNt6s@function.mps.ohio-state.edu> <SCHOUTEN.92Dec17125550@sp95.csrd.uiuc.edu>
  10. Date: Fri, 18 Dec 1992 23:39:48 GMT
  11. Lines: 10
  12.  
  13.     Declaring the C++ function using extern "C" make 
  14. sure that the compiler doesn't mangle the name so that it
  15. is callable from C.  However, if the C++ function uses ANY global
  16. variables the programm must have a C++ main so that the
  17. initialization code will get executed.  Remember that cout, cin, 
  18. and cerr, are really just globals.  You also cannot call
  19. member function directly from C you would need to add intermediate
  20. extern "C" functions between the C code and the C++ member functions.
  21.  
  22. Gregory Swedberg
  23.