Hi, Do you know a way to tell the compiler (via #pragma or similar) all functions in the C file must be reentrant? I am using a source library running in several micros and I would not like to maintain a separate source just for Keil. Thanks L
As I keep saying, This is why you should always encapsulate all your compiler dependencies in #defines!! http://www.keil.com/forum/docs/thread31.asp#msg11352 http://www.keil.com/forum/docs/thread31.asp#msg11352 eg,
#if defined( __C51__ ) #define REENTRANT reentrant #else #define REENTRANT #endif
Andy, Thanks, actually that is what I am doing right now. I cannot modify the code at all (because of legal, rather than technical issues). I would like to have something like
#pragma ALLFUNCTIONSREENTRANT #include <untouchablecode.c>
Was the "untouchable" code ever specified to be portable to the 8051? If it was, surely it should allow for this - and if it doesn't, it doesn't meet its spec?
The code is full ANSI C. It is a propietary protocol stack we purchased in order to speed up ourprototype. Everything works fine but I cannot release it to production with the modified code :(
"It is a propietary protocol stack we purchased in order to speed up ourprototype." That is very often the best way to go; particularly with protocol stacks - provided you ensure that it is compatible with your target and development tools. If this stack requires reentrant functions, and is supposed to work with 8051 targets, then it should provide the necessary support without you having to modify the source. Have you taken this up with the vendor? Are you sure that you really need to make everything reentrant? I recently worked on a project with a bought-in stack where the client had defined functions as reentrant to get around C51's function-pointer limitations. A reading of the Keil app notes & knowledgebase articles on this subject showed that it was not necessary.
Andy, Half of the code uses pointer to functions having local variables. I can redo the calling tree by hand in order to avoid using reentrancy, but it will take some time checking and profiling the code. Talking with the vendor is ongoing, but all of that is besides the point. I will put that request to Keil to see if they can put a REENTRANT directive to the compiler... Thanks L
Since the project becomes more and more complicated (around 512K), I would like Keil to add a compiler option to force all functions to be reentrant, otherwise function pointers will be hard to handle.
3000
Since the project becomes more and more complicated (around 512K),
then why on earth do you use a '51? When the dinosaurs roamed the earth there were legit reasons for using '51 banking to huge memories, but with todays low prices for e.g. the ARM there is no reason to manhandle projects of such size into a '51.
Erik
Note the date of the original post...!!
I just noted that a meaningless post was used to wake up the thread.
I hope it is Keil testing, not someone thinking childish pranks are funny
Guilty, m'lud: http://www.keil.com/forum/1