[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LYNX-DEV C++/C mix
From: |
Laura Eaves |
Subject: |
Re: LYNX-DEV C++/C mix |
Date: |
Mon, 18 Aug 1997 04:08:33 -0400 (EDT) |
> Date: Sun, 17 Aug 1997 13:39:43 -0400 (EDT)
> From: Wayne Buttles <address@hidden>
>...
> Before, I wrote:
> > > I need a crash course on mixing C++ and C if anyone can oblige. I have a
> > > C++ library that [supposedly] allows djgpp programs to use winsock. This
> > > could mean a lynx for Win3.x, but only if I can find a way to mix them.
> > >
> > > The winsock.h that comes with it is itself written in c++. It contains
> > > classes and substituting that for the normal tcp libraries results in a
> > > lot of:
>
> On Sun, 17 Aug 1997, T.E.Dickey wrote:
> > I don't think there's a reliable way to call C++ from C, except (possibly)
> > by adding a layer in C++ that is defined w/o classes in its interface
> > (otherwise, the name-mangling produces this sort of problem).
>
> Ahhhh, it is all coming back to me now. I have to write a set of
> interface functions to access their interface library. Thanks for the
> clue.
If you mix C and C++, you need to compile the file containing main()
in C++ and you need to link using the C++ compiler command
(CC, g++ or whatever) in order to handle static initialization,
template instantiation (if any), or excepetion handling (if any).
If you write interface functions in file.C, be sure to declare them
extern "C" so the c++ compiler won't mangle their names.
I've always found mixing C and C++ to be a pain, but it is doable.
--le
;
; To UNSUBSCRIBE: Send a mail message to address@hidden
; with "unsubscribe lynx-dev" (without the
; quotation marks) on a line by itself.
;