<div class="gmail_extra">Hi Charles,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for replying!</div><div class="gmail_extra"><br></div><div class="gmail_extra">I don't believe it's a problem calling C functions, you just have to declare them with 'extern "C"' to avoid name mangling (I think??). </div>
<div class="gmail_extra"><br></div><div class="gmail_extra">The issue is, when I want to use C++ I have to switch the implementation file to ".mm", which is a Objective-C++ file. As soon as I do this Xcode starts complaining about 'class_addmethod()' in my setup function. The weird thing is that it only applies to 'class_addmethod()'. For example, 'class_addbang()', 'class_new()' all work fine. </div>
<div class="gmail_extra"><br></div><div class="gmail_extra">It seems like it's an issue only with this function, and it looks like <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html">class_addMethod is already a function used by Objective-C </a> I think maybe there's some namespace issues, but I have no idea how to resolve this. </div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
wrote wrapper functions to export a C-callable public interface to C++ functions. </blockquote><div><br></div><div>Yep, this is what I'm doing now. A bit annoying because I was so close :) </div><div><br></div><div>Thanks for your help!</div>
<div><br></div><div>Cheers,</div><div>Joe </div><br><div class="gmail_quote">On 27 April 2012 04:10, Charles Henry <span dir="ltr"><<a href="mailto:czhenry@gmail.com" target="_blank">czhenry@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys<br>
<br>
The part that I don't get is how to call C functions from C++? I don't<br>
think I've even tried that before. Have you?<br>
Joe: I've built externals that just call C++ functions that I declared<br>
with extern "C" or wrote wrapper functions to export a C-callable<br>
public interface to C++ functions. Best suggestion I've got is to<br>
identify which functions you've got are going to be public and which<br>
ones are private and plan out how you're going to declare them.<br>
<br>
Chuck<br>
<div class="HOEnZb"><div class="h5"><br>
On 4/26/12, Ed Kelly <<a href="mailto:morph_2016@yahoo.co.uk">morph_2016@yahoo.co.uk</a>> wrote:<br>
> Hi Joe,<br>
><br>
> Have you thought of using ofxPd?<br>
><br>
> I'm involved in the creation of an app for the iPhone right now, and we're<br>
> using ofxPd from Dan Wilcox:<br>
> <a href="https://github.com/danomatika/ofxPd" target="_blank">https://github.com/danomatika/ofxPd</a><br>
> Since Openframeworks is a bunch of C++ wrappers for various libraries, ofxPd<br>
> adds Pd to the libraries that you can work with in C++.<br>
> Then you can call the setup function within the xcode build, and your object<br>
> will work in libpd (i.e. ofxPd) in the app environment.<br>
> Bear in mind that Apple do not like GnuGPL licensed stuff, so I've created<br>
> BSD licensed versions of some of my own Pd externals for this project.<br>
><br>
><br>
> And the app works. We're in the final stages now, so I'll post to the list<br>
> when it's complete!<br>
> Best,<br>
> Ed<br>
><br>
><br>
> Gemnotes-0.1alpha: Live music notation for Pure Data<br>
> <a href="http://sharktracks.co.uk/" target="_blank">http://sharktracks.co.uk/</a><br>
><br>
><br>
> ________________________________<br>
> From: Joe White <<a href="mailto:white.joe4@gmail.com">white.joe4@gmail.com</a>><br>
> To: pd-list <<a href="mailto:pd-list@iem.at">pd-list@iem.at</a>><br>
> Sent: Thursday, 26 April 2012, 16:51<br>
> Subject: [PD] [Pd] Compile external with C++ compiler?<br>
><br>
><br>
> Hi all,<br>
><br>
> Thought I might as well ask this here because you guys know everything :)<br>
><br>
> I'm writing an external to be built into an iOS app that's running Pd. The<br>
> catch is I need to interface with a C++ library within the external.<br>
><br>
> The external builds and runs fine if I'm using the C compiler (in Xcode) but<br>
> I can't access the C++ library functions. If I switch it to compile in C++<br>
> (by changing the objective-c file from .m to .mm) then I can use the C++<br>
> library functions but it complains that it can't find 'class_addmethod'<br>
><br>
> 'No matching function for call to<br>
> 'class_addmethod'<br>
><br>
> I've tried declaring the setup function as C code like Katja explains on her<br>
> site:<br>
> extern "C" void external_tilde_setup(void) { }<br>
> But that still didn't seem to work. I was also going through the list and<br>
> found this thread but I'm not sure if it's the right approach. Plus I'm more<br>
> of an audio guy than programmer :)<br>
><br>
> Any ideas would be much appreciated.<br>
><br>
> Thanks,<br>
> Joe<br>
> --<br>
> Follow me on Twitter @diplojocus<br>
><br>
> _______________________________________________<br>
> <a href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>
> UNSUBSCRIBE and account-management -><br>
> <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br>
_______________________________________________<br>
<a href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Follow me on Twitter @diplojocus<br>
</div>