-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On Feb 21, 2012, at 11:00 AM, IOhannes m zmoelnig wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2012-02-21 16:36, katja wrote:
Hello,
I'd like to know opinions from experienced developers about the use of C versus C++ for dsp libs.
I'm planning to write a compact library with audio analysis functions, to be used with Pd in the first place, but meant to be portable to other real time dsp frameworks. This project will contain several routines which must share one interface to Pd, and C++ will be most convenient for it. I've used C and C++ for Pd classes before, and both seem to work properly and efficient. But I lack experience to know on beforehand if there is some disadvantage of using C++ for a reusable dsp library. This will be my first. Quite some dsp libs are written in C, even today. Is there good reason to refrain from C++'s conveniences for writing classes, and use C instead?
one problem with C++ is that name-mangling is different depending on which compiler/linker you are using. this basically means, that you cannot use your C++-library binary made with g++ in an application/... build with e.g. M$VC.
note that you can avoid this, if you provide a public "C" API, and use C++ only as an implementation detail (e.g. and pass classes around as anonymous structs)
Hey Katja,
To throw in my related experience mirroring what Matju and IOhannes are saying, if you also care about making it easy to deploy, and you plan on doing the work to make it easy to deploy, you probably are going to spend less time if you do it in C. If you look at all the fundamental libraries that are ported and used everywhere, they are written in C. freetype, ffmpeg, iconv, libjpeg, libpng, zlib, bzip2, sqlite, libquicktime, gmerlin, etc. And of course... Pd :-)
.hc
"We have nothing to fear from love and commitment." - New York Senator Diane Savino, trying to convince the NY Senate to pass a gay marriage bill