From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: c and c++ in the same program? Date: Wed, 15 Jan 1997 19:02:05 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 25 Message-ID: <32DD9A2D.3505@cs.com> References: <32dd111a DOT 70513538 AT redwood DOT cs DOT sc DOT edu> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp105.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Daniel Boyer wrote: > > My question > is can I intermix the code or do I have to rewrite it all (I only know > bare minimal C...I when straight from pascal to C++ without ever being > taught C, so I don't really want to go back and try to learn C just > for this program.)? Thanks, Daniel Boyer It's not very difficult. Take any code that is written in C and wrap its declaration in "extern C { ... }". This instructs the compiler not to name-mangle the resulting identifiers according to C++ rules, but rather to leave them alone and call them as C functions. You need to put the "extern C" bit in the header file(s) that declare the C functions. BTW, this doesn't interfere with those same header files being used for C programs. Take a look at any of the DJGPP header files to see how they handle it. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | Plan: To find ANYONE willing to | http://www.cs.com/fighteer | | play Descent 2 on DWANGO! | Tagline: | ---------------------------------------------------------------------