[PD] Using C++ sources for externals
barknech at ph-cip.uni-koeln.de
Wed Feb 6 21:30:24 CET 2002
> The trick is to have C functions (global functions in C++ I guess) exported
> and to work in C++. C++ is geared up nicely for this. I have a version
> of my library that builds in C++ - I'll dig out the source code later if I
> a chance.
That would be nice. In the meantime I have read some source code and the
comp.lang.c++ FAQ. Basically it seems to me that there are two ways to
reuse C++ libraries/header/cpp files:
<now I'll start jabbering, as I don't fully understand the following ;) >
1) Wrap it up with CPPExtern of GEM or something similar, maybe more
sophisticated - and code in pure C++ yourself, with OO and all that
bells and whistles.
2) Leave out the _real_ object orientation and write the main external code
in C++, but not using a lot of the C++ features. I think, that's what Yves
did in his stksitar adaption of Perry Cooks C++(!)-library STK. Reading
through "stksitar~.cc" all this looks a lot like your typical C-external
code, except usage of a sitar class which comes out of a C++-class defined in
sitar.h (by P.Cook?!) Later on the setup function "stksitar_tilde_setup" is
extern "C" void stksitar_tilde_setup(void)
So obviously this function needs special treatment, whereas the others
work without the extern declaration.
Why does 2) work? Can I just code right away in C++, and then just declare
the _setup function as 'extern "C"' and all is well? I don't think so, but
where is this the right, or the convenient way to go?
Frank Barknecht <barknecht at dradio-online.de>
-= www.dradio.de =-
DeutschlandRadio-Online * Redaktion Köln
tel 0221 - 345 1471 * fax 0221 - 345 1480
More information about the Pd-list