>> I have a header file. In it, I declare a variable like this: >> >> extern volatile uint32_t millicnt; // Counter for milliseconds >> >> That header file is #included at the top of my main project file. It >> is also included at the top of its corresponding .c file. However, if >> I try to use the variable millicnt in either of those two files, I get >> a linker error about an undefined symbol. This is a linker error, not >> a compiler error: >> >> :0: error: (499) undefined symbol: >> _millicnt(dist/default/production/LED_Faceplate_v1.production.o= bj) >> (908) exit status =3D 1 > the extern is a declaration, telling the compiler that the=20 > variable will be defined somewhere else in the project. > > But, you have to define it somewhere, and only once: > volatile uint32_t millicnt; > so that millicnt actually exists. What he said. One thing I wanted to add. All the C compilers that's I've worked with allow the declaration with the extern qualifier to appear in the file where the variable is defined. This allows you to use the same header file in _all_ the source files of your project. For example (heavily trimmed): xyzdec.h extern volatile uint32_t millicnt; // Counter for milliseconds main.c #include "xyzdec.h" main() { snafu(); fubar =3D millicnt; } subr1.c #include "xyzdec.h" volatile uint32_t millicnt; subr2.c #include "xyzdec.h" snafu() { millicnt =3D rint(); return; } When the compiler processes subr1.c, it ignores the extern qualifier on millicnt. If the variable is allocated in two or more source files, then the linker will catch that error. > The linker is complaining that you haven't defined it. > In other news, I found another XC8 compiler bug today! I disagree. For the compiler to catch this error, then all of the source files in a project would have to be compiled at the same time. This is impractical on a large project or if you are including complex libraries. Lee Jones --=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 .