On 25 Sep 2005 at 15:41, lehighuboy wrote: > > The code is segmented to several C files by function, and a few > variables are shared across functions. I defined those variables in > the first compiled C file, however the other functions in subsequent > files doesn't see them during the compile. I rather not lump > everything into one file therefore I wanted to define global variables > for all C files. This looks like a C problem, not a LPC2000 specific problem. If you define a global variable int foo; in one C module, and you want to access it from a different module, then you need to define extern int foo; in the other module. This is standard C. I suggest that you buy a book on C programming. If you are still struggling with basic C concepts, then writing C for an embedded processor is going to catch you out at some point. Just do not buy anything written by Herbert Schildt. "Kernighan and Ritchie, The C Programming Language, 2nd Edition" is a good book to get. Regards Anton > Thanks, Garrett > > --- In lpc2000@yahoogroups.com, "Anton Erasmus" <antone@s...> wrote: > > On 25 Sep 2005 at 4:11, lehighuboy wrote: > > > The following question > involves an LPC2129 and Keil ARM IDE, AA and > > CARM compiler. > > > > > Are global variables defined in the startup.s file? And, if that's > > > correct, then where should the code be placed? Finally, how would > you > > define a global float, unsigned int, char, and const char > variables? > > (please respond with examples) > > > > Thank you for > your help! > > > Why would you want to define global variables in the > startup.s file ? > Define them as you would when writing normal C > code. The only thing > the startup.s file does, is to setup a suitable > environment for the C > application to run in, as defined in Standard > C. > > Regards > Anton Erasmus > -- > A J Erasmus > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> Fair play? Video games influencing politics. > Click and talk back! > http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/dN_tlB/TM > --------------------------------------------------------------------~- > > > > > Yahoo! Groups Links > > > > > > -- A J Erasmus
Message
Re: [lpc2000] Re: Global Variables
2005-09-25 by Anton Erasmus
Attachments
- No local attachments were found for this message.