Link to home
Start Free TrialLog in
Avatar of aolXFT
aolXFT

asked on

Accessing C++ Compiled libraries.

Hi

I was just wondering if there was anyway to access C++ Libraries through C.

I know that C cannot support the objects that C++ supports, but lets say for example there was a function written in C++ like

int myfunc(int num){
  myClass myclass();
  myclass.printNum();
  return myclass.getNum();
}

Although this serves no useful purpose, I was just wondering, that if you wrapped object handlers up in functions, like in the above, could you use them in C.

What made me curious about this, was that Python is written in C(I believe), and it can Handle QT stuff(which is written in C++).

 
ASKER CERTIFIED SOLUTION
Avatar of mtmike
mtmike

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cup
cup

To add to mtmike's answer, extern "C" tells the compiler not to mangle the names so that the names can be resolved during the link process.
Avatar of aolXFT

ASKER

So that's what extern "C" does, thanks mtmike.

Accepting answer now.