6.3.6.3.4 User Makefile Project – Parse Macros

You can parse and add macros for MPLAB XC C compilers to your makefile project. To do this you need to call the compiler on the command line with the relevant arguments and copy the whole output to the first panel of the Parse macros dialog.

To run the compiler on the command line, you will need a C file. For this example, use the code below and paste into a file named xcmain.c:

#include <xc.h>
void main(void) {
return;
}

Ensure that your computer knows the Path to your MPLAB XC compiler. Then execute the following on the command line:

xc32-gcc -dM -E xcmain.c > macros32.txt

The MPLAB XC32 C compiler is used, not the MPLAB XC32++, so xc32-gcc is the executable. The option -dM tells the preprocessor to output only a list of the macro definitions that are in effect at the end of preprocessing. The option -E stops execution after the preprocessing stage. The redirect (>) character sends the output into the file macros.txt.

For other MPLAB XC C compilers, you can use:

xc16-gcc -dM -E xcmain.c > macros16.txt
xc-dsc-gcc -dM -E xcmain.c > macrosdsc.txt
xc8 --pre -v --chip=8BitMCU xcmain.c > macros8.txt

where 8BitMCU should be replaced with your 8-bit device. The macros8.txt file will also require additional editing to isolate the macros from other text in the file.

To open the Parse macros dialog:

  1. Right click on the project name and select Properties.
  2. Under Categories, select Makefile.
  3. Under Set User Makefile properties, go to User Macros and click on the Parse button.

To parse the macros:

  1. Copy and paste the contents of macros.txt into the dialog left panel.
  2. Check the checkbox for your MPLAB XC C compiler, in this case xc32.
  3. Click the Parse button.

Click a button to Replace the current contents of the User Macros text box, Append to existing text in the text box, or Cancel to leave the existing text unchanged.

Figure 6-31. Parse Macros Dialog