[PD] pd external c++ example

Christof Ressi christof.ressi at gmx.at
Sun Jun 3 21:34:43 CEST 2018


> - surround the whole code with extern "C" { ... }

I think you only have to do this with the setup function because that's the only function which gets exported (and therefore mustn't have namemangling).

>        candidate function not viable: no known conversion from 'int' to
>        't_atomtype' for 6th argument
> EXTERN t_class *class_new(t_symbol *name, t_newmethod newmethod,

is you're 6th argument a '0'? looks like in C++ you can't pass an int where an enum (t_atomtype) is expected. try to pass 'A_NULL' instead.

Christof

> Gesendet: Sonntag, 03. Juni 2018 um 09:40 Uhr
> Von: "Joseph Larralde" <joseph.larralde at gmail.com>
> An: pd-list at lists.iem.at
> Betreff: [PD] pd external c++ example
>
> Hi list,
> 
> Some time ago I wrote a bunch of pd externals in C++, some using flext, 
> some by tweaking xcode projects until they worked.
> Yesterday I've been trying the examples from the 
> pure-data/externals-howto github repo, with the idea in mind to write my 
> own clean pd library.
> The first example compiled right away, so I decided to tweak it to use 
> C++ instead of C.
> 
> Here is what I did :
> - rename helloworld.c to helloworld.cpp
> - surround the whole code with extern "C" { ... }
> - change class.sources = helloworld.c to class.sources = helloworld.cpp 
> in the Makefile.
> 
> And I got this error :
> /Applications/Pd-0.47-1-64bit.app/Contents/Resources/src/m_pd.h:476:17: 
> note:
>        candidate function not viable: no known conversion from 'int' to
>        't_atomtype' for 6th argument
> EXTERN t_class *class_new(t_symbol *name, t_newmethod newmethod,
> 
> I tried to add CXX = g++, then CXX = clang, then CXX = llvm in the 
> Makefile, none of which changed anything.
> (I'm using OSX 10.11.6)
> 
> Before starting to play with more settings I don't fully understand 
> everywhere, I thought I'd ask for help here.
> Any suggestions ?
> By the way, I think a basic C++ example in the repo would be useful.
> 
> Also, if some advanced user is able to give me a good reason to 
> (cross-compatibility or whatever), I could consider switching back to C.
> But I don't see any reason to do so, except maybe for a small gain in 
> size and/or performance ...
> 
> Thank you in advance for any replies,
> Joseph
> 
> 
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
>



More information about the Pd-list mailing list