>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >On Behalf Of Alan B. Pearce >Sent: 25 October 2007 14:57 >To: Microcontroller discussion list - Public. >Subject: Re: [EE] Global variables in projects with many C files. > > >>For a further refinement along these lines, see Problem #1 here: >> >> http://www.circuitcellar.com/library/eq/160/index.htm > >That is a nice way of doing it Dave. The example wasn't very good IMO, it would have made more sense to have shown the GLOBAL macro being applied to data objects rather than functions simply because the 'extern' qualifier is optional for functions. In the vast majority of code I have seen they have not been used, though some coding style guides recommend they are included. Just to clear up any confusion: DECLARATION: You are describing the variable or function to the compiler e.g. name, type and scope. DEFINITION: Allocates memory for the object, defines the actual code for a function. The rule is DEFINE ONCE, DECLARE MANY i.e. you must only ever define a function or data object once in a project, but you can declare it as many times as you want, though for practical purposes you declare it once in a header file and include the header in multiple C modules. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist