I just wanted to mention that there is a commonly used construct that=20 can confuse the issue if you're looking at someone else's code. Sometimes, you'll see a header file which both defines and declares a=20 variable like this: // file: myutils.h #ifndef MYUTILS_C #define EXTERN extern #else #define EXTERN #endif // MYUTILS_C EXTERN int my_util_var; // always declared, but only defined if=20 compiling myutils.c Then, myutils.c would have this: // file: myutils.c #define MYUTILS_C #include "myutils.h" #undef MYUTILS_C And any other file that needs to reference myutils.h #includes it=20 normally, without the bracketing #define and #undef What this does is to define (allocate storage) in the .h file, which at=20 one time was (and possibly still is) bad practice, but is legal. When=20 myutils.c includes myutils.h, my_util_var is declared and defined=20 (storage is allocated) because EXTERN is not defined. When other files=20 #include myutils.h without the MYUTILS_C definition, EXTERN is defined=20 as extern, so my_util_var and friends are declared, not defined. I like this construct because it allows defining and declaring in one=20 spot, and can result in less searching in files to find where the=20 variable is defined. I don't recommend trying this unless you see some clearer examples of=20 it. Just wanted to share an observation I've made looking at OPC (other=20 people's code). Joe W On 3/29/2015 2:46 PM, Josh Koffman wrote: > On Sun, Mar 29, 2015 at 3:46 AM, Jesse Lackey = wrote: >> Hi Josh, the extern is a declaration, telling the compiler that the >> variable will be defined somewhere else in the project. The point being >> that you can then use it in your code in that .c file or in numerous .c >> files. >> >> But, you have to define it somewhere, and only once: >> volatile uint32_t millicnt; >> >> so that millicnt actually exists. Typically you'd do this in whatever >> .c file has your main(). >> >> >> >> The linker is complaining that you haven't defined it. >> >> In other news, I found another XC8 compiler bug today! > Ah...that makes more sense. I looked at some examples of how to use > extern, but most didn't show the definition and declaration as > separate, and I'd guess that's where my coding was different. > > I will say that that the most challenging thing so far about switching > from assemby to C has been variable management both internal to files > and across multiple files. Yikes. > > Currently downloading the latest non-beta MPLABX and XC8 by the way. > > Josh --=20 Joe Wronski jwronski@stillwatereng.net www.stillwatereng.net --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .