Re: How do you use Preprocessor directives for embedded program
I use them very frequently for Debug/Testing builds.
Like a #ifdef SERIAL_DEBUG to enable/disable blocks of code if you need serial debugging output when developing, but then just undefine SERIAL_DEBUG for release code.
Or I also have systems with smaller PICs where I want periodic serial logging functions for running in a temperature chamber, but in actual release code I need that codespace to fit in a bootloader. In that case I can put all my serial logging functions and calls into a big #ifdef ENABLE_SERIAL_LOGGING block so it's nice and easy to add/remove.
Or even just for defining constants:
#define FW_TYPE "PRODUCTION"
#define FW_TYPE "TESTING"
set your preprocessor definition to your project configuration and you can just select your config from the MPLAB X dropdown to automatically enable/disable code as appropriate.