Link to home
Start Free TrialLog in
Avatar of klopex
klopex

asked on

Inserting C code into a C++ program

I am working in C++.  We downloaded some C code from ITU that implements some compression algorithms.  I am rather new to C++ and I want to know what is the right approach to using C code in C++.

Should I translate it all into C++ classes?
Is there a common alternate approach?

All of the code will be compiled together on Linux using g++ 3.2.x.
Avatar of Member_2_1001466
Member_2_1001466

To use them as they are you need to change the function declaration to be extern "C":
in the header file add:

extern "C" {

.. all function prototypes.

}
SOLUTION
Avatar of Member_2_1001466
Member_2_1001466

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
ASKER CERTIFIED SOLUTION
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 klopex

ASKER

Thank You.  I had been considering writing the wrapper class so I wouldn't have to edit good code.  I think that is what I am going to do...