[PD] C++ for reusable dsp lib - or better use C?

Hans-Christoph Steiner hans at at.or.at
Tue Feb 21 17:12:55 CET 2012


-----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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJPQ8KOAAoJEJ8P5Yc3S76BJqcP/ikfoCnYF5jYY7XcPR4AX9l4
yRKbsvrIh3Ikpwa0CoQJj5hFOoLS3GK/8xpPhrVOlo66nvwKKsCNwf/KjSie1DlO
cl6xLENRnWEnjZHJ57fTqNVP+qxUv6Z4FVV/SipSMT7CSv+jl/bmrUaP8tMD2Myy
ZywAVYPNL/I0e9HTESA1bCZq1Up5nwTDjCKu8iNSQoJ0XAD6Q06UHxjMMl71mCBg
QuCrw09s2yIkoSOEQKjcPXtO/TEahtKpmCgJa3HeXntSoMsDwld8sIeZRnPile3m
DGQ7MqaEYD/0ZI0yScn5Ai3qecW4OP94r1gNv0lqk7PObulj4R3Klw+o2YFItucj
tRAqGF1vng9kstCGw6O2tRJooaRIvyLbc9sd+JtpG6clk+8Q9gR3y+LxRKUIz2NP
XQ7uAoPHWsMWsEdLMX/yXz2vhX6ZuWqP32TPn9MyMxXcRnFIn5qbV9N3sgG/ur+7
qy1+dA3/2HxC6HspIu+TRyAcrZPIj9xIYfHVE4ZsHYLcR5mhy+8reO+TXNiOvP22
+JWZ/QKrDhlPMmErRlLmMZvj4kOtLckpsqTkkLkgO/j6dMA/qXfyl+OkJfpov4K+
09BrBw9FLWeA6PtOhut5piCC8hTs6d7mvyUZ+OXnRK5u3XYmFWA/kEkhgSotlXdj
Qi5NWbgnahxqMlojuf8m
=lEx2
-----END PGP SIGNATURE-----



More information about the Pd-list mailing list