We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have created a small timer library, in which it call the timer handler by function pointer in the interrupt.And i now found that the handler local data would be corrupted because of the data overlaying.But i created this library to let others use it, but they would be bothered about data overlaying. so is there any way to exclude a function from overlay analysis when the user add the function as a timer handler by calling my library,or at least ,disable data overlaying when anyone use my library? OVERLAY directive is a linker directive so it seems no way to use it in the source code.....
Function pointers are well known to be problematic in Keil C51.
Why deliberately create problems? Why not just avoid the problem completely by not using a function pointer?
But my implementation requires function pointers.
Maybe you should then select a processor architecture that works well with function pointers?
OK...maybe i should give up
You have 2 choices:
1. Make the implementation suitable to the target architecture;
2. Choose a target architecture suited to the implementation.
Pick one!
No need to give up - I'm sure it's perfectly possible to do without function pointers...
But my implementation requires function pointers. baloney, I challenge you to show me a code snippet that requires function pointers and I'll prove you wrong
And that makes it a bad implementation for this architecture. But that's no reason to give up. It just means you have to learn more about the peculiarities of your chosen architecture before making the jump from "problem" to "implementation" again.
Just because a particular algorithm or technique is elegant or well-reputed in some architecture or other, or even many of them, by no means allows the conclusion that it's also a good match for every other architecture or problem domain. That holds more strongly the more quirks the target architecture has. And the 8051 has about as many of those as you get, while still allowing for a bona-fide implementation of the C programming language.