re: extern "C" on templates


#1

Anyone here knows how I can use templates for my C/C++ plugin?
Hunting around google and also from the error messages it seems using extern “C” doesnt work on templates. Is there a way to get around this? Or must I actually explicitly declare the type instead of using templates?

Thanks for the help.


#2

You need ‘wrapper’ functions for your templates. From another site I came across:


template<class T> T foo(T t) { ... }
extern "C" int   foo_of_int(int t) { return foo(t); }
extern "C" char* foo_of_charp(char* p) { return foo(p); }


#3

yeah I realized way too late, already spent a good time making the variables explicit.
thanks


#4

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.