C++ Learning Community Forum
August 01, 2010, 03:22:42 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: extern "C" in DLL with classes  (Read 144 times)
vivendi
semi-N00b
**
Posts: 31


View Profile
« on: February 13, 2010, 12:12:54 AM »

I want to create a DLL file but i'm not sure what to do. First i'll try to explain what i have.

In my dll i have the dllMain function. But i also have classes with public and private members/functions. What i want is that other programming languages have access to my functions.
So i compile a dll in C++, and someone else who is coding in C# should be able to add my DLL to this project and have access to those classes -> which gives him access to the functions.

But there seems to be a special way of creating a dll if i want to do such a thing. I know i have to use the extern "C" declaration. But how exactly do i do this?? Do i just encapsulate my classes around an extern "C" declaration? Like so:

Code:
extern "C" {
class cTest
{
public:
//functions here
}
}

So would this be enough?? I also read somewhere that i can only use structs?? Or can i use classes too this way??

Well anyway, any information is more than welcome! Smiley

Thanks for any help!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!