tags:

views:

55

answers:

1

Hello, I have a very large code, that's why I can't post here all my code, can somebody explain what might be a problem if I have an error incompatible pointer type and give me several ways to solve it, thanks in advance

just small clarification: I'm workin with pointers to functions

ptrLine createBasicLine(){
    DECLARE_RESULT_ALLOCATE_AND_CHECK(ptrLine, Line);
    result->callsHistory = listCreate(copyCall,destroyCall);          <-here
    result->messagesHistory = listCreate(copyMessage,destroyMessage); <-and here
    result->linesFeature = NULL;
    result->strNumber = NULL;
    result->lastBill = 0;
    result->lineType = MTM_REGULAR_LINE;
    result->nCallTime = 0;
    result->nMessages = 0;
    result->rateForCalls = 0;
    result->rateForMessage = 0;
    return result;
}

copyCall,destroyCall - pointers to functions

/**
 * Allocates a new List. The list starts empty.
 *
 * @param copyElement
 *  Function pointer to be used for copying elements into the list or when
 *  copying the list.
 * @param freeElement
 *  Function pointer to be used for removing elements from the list
 * @return
 *  NULL - if one of the parameters is NULL or allocations failed.
 *  A new List in case of success.
 */
List listCreate(CopyListElement copyElement, FreeListElement freeElement);

definitions of the functions

ptrCall (*createCall)() = createNumberContainer;

void (*destroyCall)(ptrCall) = destroyNumberContainer;

ptrCall (*copyCall)(ptrCall) = copyNumberContainer;
+2  A: 

I should imagine that a pointer you are using is of an incompatible type for some context in which you are trying to use it.

  1. Stop using the pointer in that context .
  2. Use a different pointer.
  3. Change the context to be compatible with the type of the pointer.
  4. Cast the pointer to a compatible type for the context.

Out of these, the last one may seem the most attractive, as it is likely to get you past the compiler pretty quickly. Sadly, it will probably make your code not work in strange and unpredictable ways.

Paul Butcher