5.14.3 Debug Macros Generated

MPLAB X IDE generates debug macros for use with Microchip language tools. Macros passed to Microchip compilers and assemblers are shown in the table below. See MPLAB XC C compiler documentation for more information.

Table 5-9. Microchip Tools Debug Macros
Macro Name Assoc. Tool Function
__DEBUG All specifies that this is a debug build
__MPLAB_<toolname>__

where <toolname> is:

  • ICDx (x=2, 3, 4 or 5)
  • ICEx (x = 4)
  • PICKITx (x=2, 3, 4 or 5)
  • REALICE
  • SNAP
XC8 specifies the hardware debug tool in use
__MPLAB_DEBUGGER_<toolname>

where <toolname> is the same as above.

XC16, XC-DSC, XC32 specifies the hardware debug tool in use
__MPLAB_DEBUGGER_<skname>

where <skname> represents the starter kit, i.e., PIC32MXSK.

XC32 specifies the starter kit in use

You can use these macros in your own code. For example:

#ifdef __DEBUG
fprintf(stderr,"This is a debugging message\n");
#endif