View Full Version : re: extern "C" on templates

01 January 2007, 06:06 PM
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.

01 January 2007, 10:30 PM
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); }

01 January 2007, 11:35 PM
yeah I realized way too late, already spent a good time making the variables explicit.

CGTalk Moderation
01 January 2007, 11:35 PM
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.