On 27/08/2012 17:13, Wouter van Ooijen wrote: >> I thought this should work: >> >> // In main.c >> #define WIDGIT_OUT LATC1 >> #include "widgit.h" >> >> // In widgit.h >> #ifndef WIDGIT_OUT >> #warning Output pin not defined! >> #endif >> /* #define WIDGIT_OUT LATC1 <-- Now in main.c */ >> >> But it appears that this doesn't work. I get errors from widgit.c about >> WIDGIT_OUT being an undefined identifier, using #ifndef/#warning in >> widgit.h also prints the message. > > This approach should work. Did you include widgit.h in widgit.c? Yes, widgit.h is also included here. The header can only be included=20 once with the usual trick of #ifndef _WIDGIT_H ... #endif I have checked the compile order and main.c comes before widgit.c. >> 2) What ways people use to write reusable code. > > Another trick (that is somewhat compiler-dependent) is to have widgit.h > include widgit-pins.h, which is in the project directory. This how it is > done in Jal. That's a neat idea, I will try this and see if I can get it to work.=20 MPLABX and HiTech (I've not moved to XC8 yet) do some things I need to=20 understand better when you add files from multiple folders into one project= .. Thanks, David --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .