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

Mathieu Bouchard matju at artengine.ca
Sat Feb 25 20:59:09 CET 2012

Le 2012-02-22 à 15:30:00, katja a écrit :

> Pd classes can be done in C very well, if procedures are not too 
> complicated and not meant to be used in other contexts.

In my practice, C is not high-level enough. So, for coding my own C++ 
externals, I use C++ together with a custom preprocessor which does a job 
similar to what SWIG does.

> For a reusable audio analysis lib I would straightforwardly use C++, 
> where it not for the considerations mentioned by Mathieu, Hans and 
> Marvin. The intricate runtime support required for C++ leads to specific 
> incompatibilities which don't exist for C.

IMHO, fighting those incompatibilities is worth it ; also, some of them 
don't exist anymore (in recent years), and some others have a workaround 
whenever you provide a C interface to a C++ library, and some others don't 
exist if you turn off try/catch/throw support.

> A collection of useful routines which may be used individually, or 
> combined as integrated analysis-engine, in the context of a framework 
> like Pd, MaxMsp, SuperCollider.

Can you be more specific about what this will be ?

> I use to link GNU C++ standard libs statically, just in case my class
> is used with a Pd which doesn't have them. This adds more than 100 KB
> to the executable size, not so nice detail.

Isn't this mostly when you use STL ? The use of STL is optional. For 
example, I almost never use #include <fstream> in C++, I still prefer 

> A C lib would not impose all these concerns on an application 
> programmer. I'm inclined to look at C once more.

Instead, a C lib will impose other concerns that C++ won't. What will 
those be ?

| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC

More information about the Pd-list mailing list