| |||||
Technical Support Support Resources
Product Information | C51: INDIRECTLY CALLED REENTRANT FUNCTIONSInformation in this article applies to:
QUESTIONI have problems passing lots of parameters to indirectly called functions. I tried to use the reentrant attribute but I could not make it work. Can you give me an example? ANSWERThe example below shows the correct definition for reentrant functions that are called via function pointers. Both the function pointer and the function itself must contain the reentrant attribute. In addition, you must setup the reentrant stack pointer in the startup code (STARTUP.A51).
long* (*indirect_func) (long l, long* lp, int i) reentrant;
long* func (long l, long* lp, int i) reentrant {
lp += i; // just for demonstration
*lp = l;
return (lp);
}
long xdata larray[100];
long *lp;
void main (void) {
indirect_func = func;
lp = indirect_func (500000L, larray, 5);
while (1);
}
MORE INFORMATION
SEE ALSO
Last Reviewed: Monday, July 18, 2005 | ||||
| |||||