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