Quote Originally Posted by sunkingac
In the C++ source, there are many class templates.
I want to convert to the templates to C code.
C does not support template classes (or classes indeed).

Templates allow the user to re-use a piece of code with different data-types.

The only equivalent conversion I can think of is to write methods, one-per unique data-type the template class is used with.

So, one template class in C++ will translate to N functions in C.

Something like this -
Code:
//Your C++ Code
  template <class T>
  class CTakeDifferentDataTypes
  {
  public:
  void DoSomething (T data);
  };
  
  // It is used as -
  CTakeDifferentDataTypes <int> mIntData;
  mIntData.DoSomething (20);
  
  CTakeDifferentDataTypes <float> mFloatData;
  mFloatData.DoSomething (1.0);
This will translate to C Code as follows
Code:
// Handle Integers...
  void DoSomethingWithIntegers (int nData)
  {
  }
  
  // Handle Bool...
  void DoSomethingWithFloats (float fData)
  {
  }
  
  // Use these...
  DoSomethingWithIntegers (20);
 DoSomethingWithFloats (1.0);
As you can see, C++ gives tremendous re-usabilty in the form of templates that you will lose when you port functionality to C.