AnsweredAssumed Answered

Codewarrior Type Casting issue when passing "void *" from a function pointer

Question asked by Charles Barnes on Apr 8, 2013
Latest reply on Sep 17, 2013 by Charles Barnes

So I have this function:

 

static void T_CALLBACK _transmit(

  void *pContext,

  TX_DATA *pTxDescriptor)

{

  CONTEXT *pLinkContext = (CONTEXT *)pContext;

}

 

That is being called via a function pointer.

 

void *pContext is being passed an address of 0x1558.

 

However, when it gets cast, it casts to 0x0AAC.  For obvious reasons, this causes problems because it is pointing to the wrong address in memory and I quickly get a long access misalign interrupt.

 

I don't fully understand what is going on or how to fix it, this is third party code and not something I do in coding, so while I see WHAT is going wrong (the address is shifted by 1, so it points to the wrong spot in memory), but I'm not sure WHY it is doing it and, more importantly, how I can fix it.

 

Outcomes