Xref: news2.mv.net comp.os.msdos.djgpp:750 From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: calling C++ from C Date: Fri, 02 Feb 1996 22:19:04 -0800 Organization: &tSftDotIotE Lines: 36 Message-ID: <3112FE58.38BB9F9C@alcyone.com> References: NNTP-Posting-Host: newton.alcyone.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Brendan Simon wrote: > Can I call/use a C++ class from within a C program ? No, you can't. > If not, can I have a wrapper style function in the C++ program which will > use the class objects ? Yes. The wrappers (which will be part of a C++ module, since you'll have to have them call the C++ constructs) will need extern "C" { ... } around them. > As I understand it, I would also need 'extern "C" {' and '}' in the C++ file. > Is this correct ?? Correct. You should also put the extern "C" { ... } delimiters around the function prototypes in the header if you intend to use them from a C++ program as well as a C program (can't hurt to do this), but remember to put the appropriate checks to see if __cplusplus is defined; i.e., #ifdef __cplusplus extern "C" { #endif ... #ifdef __cplusplus } #endif -- Erik Max Francis, &tSftDotIotE. && max AT alcyone DOT darkside DOT com || max AT alcyone DOT com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && GIGO Omega Psi && http://www.alcyone.com/max/ "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_