I am using 5.20 if it matters I have a function that is indirectly called from an array of functions. This function is contained in its own module. When I link, I get the following warning:
WARNING 16: Uncalled Segment, ignored for overlay process segment: ?CO?FACT_CON
static float code ideal_values[LAST_POINT] ={
I have a function that is indirectly called from an array of functions. This function is contained in its own module. When I link, I get the following warning: WARNING 16: Uncalled Segment, ignored for overlay process segment: ?CO?FACT_CON You know this will happen. Okay. static float code ideal_values[LAST_POINT]if I change the "code" to "const" (or remove it entirely), it will link with no warnings, but now the variable is taking up XDATA, and with only 2K of it, XDATA is VERY precious... Remember, C says nothing about const meaning "in PROM", it just means read-only at compile time (undefined at run-time if you try to write to it). So, C51 could place const data in XDATA and not violate C rules. With C51 code tables are constant implicitly so you should make any code table const as well for safety. To ensure vars. are placed in code memory you must define them with the code memory space qualifier. Your definition should absolutely be written as:
static float code ideal_values[LAST_POINT]
static const float code ideal_values[LAST_POINT];
To ensure vars. are placed in code memory you must define them with the code memory space qualifier. Your definition should absolutely be written as: static const float code ideal_values[LAST_POINT]; This was one of the several incantations I tried, and I still get the warning. It was also suggested to make sure that variable was used in the function call, and it is. Another suggestion was to place this directly in the function that uses it (since the file only has one function in it, it is ONLY used by one function, and can go inside that function), but I haven't tried this yet. Anyone else have an idea?
Okay, one thing you can try is the NOOL option for the linker. This makes all data non-overlay, so it may take up data space if you have automatic variables. If all your data is static, you will get little or no increase in data space, and the warning will go away. If you need to run in overlay mode, the other way to eliminate this warning is with the OVERLAY command in the linker. The linker is basically saying that it cannot find any reference to this object anywhere in the code. By using the OVERLAY command, you tell the linker what is going on. There are several examples in the UTILITIES manual. One of them should be what you need or close. We used this in a previous project where we used OVERLAY mode, and it worked fine. It can be a little cumbersome to use (i.e. it must be maintained when you add indirect function calls) but it does work.
Okay, one thing you can try is the NOOL option for the linker. This makes all data non-overlay, so it may take up data space if you have automatic variables. If all your data is static, you will get little or no increase in data space, and the warning will go away. can't do this... I'd love to, but I only have 2K of SRAM with VERY little free. If you need to run in overlay mode, the other way to eliminate this warning is with the OVERLAY command in the linker. I have MANY entries into my link file in regards too this. They maybe wrong though. Regardless, I have it working now, after moving the variable INSIDE the function, the warning has disappeared. I have taken this concept to several other places in my code where such problems existed, and they too are now gone. (thanks to Mark for suggesting this to me... with only one function in the file, I orignally didn't care about localizing the scope as much as possible, because it just didn't matter.) I'd still like to know why this happenned, I hate ghosts.
Take a look at this link in the knowledgebase. It may help. http://www.keil.com/support/docs/203.htm The reason you get the error you do is that the array is accessed (probably) by one of your indirect functions. Make sure that you are properly creating the call tree (manually) for these routines. Check the following URL for a lot of information about using function pointers: http://www.keil.com/appnotes/docs/apnt_129.asp Keil Support
It seems that you do not directly use the variable in the function. If you want to define the variable using the keyword "_at_" and access it by the pointer you give the address directly, just ignore this warning or put a line as following, somepointer=ideal_values; Sorry for my "cool" English. an Chinese
This is just a suggestion. I declare an array of function pointers to solve similar problem in my current project. It works without warning, the array is placed in code memory, and the overlay analysis is used for the whole project. You could try this: static const float (code* code ideal_value[LAST_POINT])(void) = {fnct1, fnct2}; This simply declare an array of pointers to functions that return float and take no argument. The array is placed in the code. Invoke the function by: x = ideal_value[i](); or x = (*ideal_value[i])(); I hope this solve your problem. David Lin