Hi all,
pretty glad to find this page. i am a newbie and need your help please!!!
This is somehow related to information hiding.
function A is high level, function B is in between, and function C is a library function, which is a low-level driver. I need function A to call function B, then function B passes all parameters it receives from function A to function C. So function B hides function C from function A.
The low-level driver library function C requires 4 parameters
a) address of the structure
b) address of the stack array
c) address of the message buffer
d) length of the message buffer
and it has the following prototype
void functionC(structC *tcb, unsigned int *stack, unsigned char *mes_buf, unsigned int mes_length);
Now I need to write my function B to act as a middle-man between function A and function C, so that the high-level function A doesn't need to know anything about function C. All function B needs to do is to pass all parameters from A to to C.
I tried the following prototype for function B
void functionB(structC *tcb, unsigned int *stack, unsigned char *mes_buf, unsigned int mes_length);
then use function A to call it with
functionB(&tcb, &stack[top_stack-1], &mes_buf, mes_length);
but it did pass all parameters to function C correctly.
Then I tried this prototype for function B
void functionB(structC tcb, unsigned int stack, unsigned char mes_buf, unsigned int mes_length);
then use function A to call it with
functionB(tcb, stack[top_stack-1], mes_buf[0], mes_length);
but it still did not work.
Both implementations got compiled and linked successfully though, and none worked.
There must be something wrong with my code, and there must be at least one way to do it, but I don't know. Please, help. I don't know what to do now.
Thanks in advance,
Vien.