Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/01/02 13:04
Read: times


 
#31829 - RE: KEIL: How to send a table to a function
Stephane:
In your .H file simply put a declaration of the variable......

extern code U8 picture[];

In <big><big>ONE</big></big> of your source files, where you want to collect the definitions of the graphics together , provide a single definition of the variable.....

code U8 picture[]={0x00,0x01,0x02.................0xFE}; /* data you need */

When you put the definition in the .H file, as Andy has said, you cause the C compiler to make new instances of the variable into each compiled file where you had included the .H file. Then you have several copies of this data which is NOT what you wanted.

Now concerning your other issues, Put data like this in the CODE space. The only reason you would want to put it in the XDATA would be if you wanted to modify the data at run time. Since it is graphic bitmap data I suspect that you do not really want to be changing it at run time so just put it into the CODE space which is considered a read/only space at run time. Note that If you put it in XDATA as initialized data you are causing the C compiler to have to generate special code at startup time to have to copy the data from CODE to the XDATA space anyway..

And finally:
In C language when you declare a variable as:

U8 picture[]={...some data...};

..picture is an array and using picture as a variable name in the C code gets treated as a pointer. So you can see that picture and &picture are really the same thing. Please note however it is more correct to say that picture and &picture[0] are equivalent but many C compilers are a little more free on the interpretation.

Hope this helps
Mike Karas


List of 11 messages in thread
TopicAuthorDate
KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table to a function            01/01/70 00:00      
RE: KEIL: How to send a table - James            01/01/70 00:00      
RE: KEIL: A-men Andy            01/01/70 00:00      
RE: KEIL: global variables            01/01/70 00:00      

Back to Subject List