• Advertisement
Sign in to follow this  

extern "C" with template?

This topic is 2617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to define a template class inside my library but when I use extern "C" which I use on all other functions and classes I export from my dll I get a syntax error. Why and is there anyway around it?

Share this post


Link to post
Share on other sites
Advertisement
Well, I guess the long and the sort of it is that templates can't have C linkage. To be honest, it really doesn't make sense in the context of templates anyway, since they're compiled when they're used at the call site. The simple solution is that you don't need to have your templates exported from a DLL file, since the client code should have access to the complete template definition anyway, although there are some caveats. Can you be a little more specific in what you're trying to accomplish?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement