top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: What is wrapper function and how it is written in C language ?

0 votes
997 views
C: What is wrapper function and how it is written in C language ?
posted Jul 15, 2017 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Wrapper function gives you flexibility add extra functionality before or after execution of actual function.
Using macro it is written

define WRAPPER(fun, arg1, arg2) \

{\
ret = fun(arg1, arg2);\
return (ret); \
}

In case later on if prototype is changed for fun, it starts taking three arguments you have to change this MACRO definition.
In all places where it is called you don't need to change.

define WRAPPER(fun, arg1, arg2) \

{\
int arg3;\
ret = fun(arg1, arg2, arg3);\
return (ret); \
}

For end user it is still same number of arguments that need to be passed through WRAPPER.

answer Jul 18, 2017 by Harshita
Similar Questions
...