title: Passing void to a parameter of incompatible type?
body: <p>I'm attempting to use a C function within my Objective-C project, and I'm having trouble getting them to mix.</p>
  
  <p>I have the following function:</p>
  
  <pre><code>// 1. Pass in the cost function which takes in an array and gives out cost and gradient at the given input.
  // 2. xVector should contain the initial point which is will be modified to reflect the optimum point
  // 3. nDim is the dimension of xVector
  // 4. maxCostCalls is the maximum number of times the cost function may be called
  // return value:  1 -&gt; Num of Cost function calls exceeded max specified in the argument. 2-&gt; line search failed
  
  int fmincg(void (*costFunc)(double* inputVector, double* cost, double* gradVector), double* xVector, int nDim, int maxCostFuncCalls); xVector, int nDim, int maxCostFuncCalls);
  </code></pre>
  
  <p>Here's the function I'm passing into the first parameter:</p>
  
  <pre><code>static void _fmincg_evaluate(id thisClass, LKDataset *inputFeatures, LKFeature *outputFeature, LKMatrixObject *initialWeights, double cost, LKMatrixObject *optimizedWeights) {
      cost = [thisClass costUsingLogisticRegressionWithInputFeatures:inputFeatures outputFeature:outputFeature andWeights:initialWeights];
      optimizedWeights = [thisClass optimizeWeightsUsingGradientDescentForInputFeatures:inputFeatures outputFeature:outputFeature andWeights:initialWeights];
  }
  </code></pre>
  
  <p>Finally to call fmincg I do the following:</p>
  
  <pre><code>fmincg(_fmincg_evaluate(self, inputFeatures, outputFeature, self.weights, cost, optimizedWeights), inputFeatures-&gt;matrix, inputFeatures.elementCount, 50);
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <blockquote>
    <p>Passing 'void' to parameter of incompatible type 'void (*)(double *, double *, double *)'</p>
  </blockquote>
  
  <p>Maybe it's the lack of sleep, but I'm a bit confused, being that I'm new to C.</p>