Jump to content
  • 0

Preprocessor defines for XC32 used to select include file



  • Member

I am trying to pass an include file name on the command line to XC32 to select the file to include in the code. Don't ask why, this is not my code, I am just trying to compile it with this compiler without modifying the code ...

I am passing 


but the compiler does not seem to like this, error message is 

 error: #include expects "FILENAME" or <FILENAME>

Anyone know how to bend XC32 to my will here to do this correctly?


EDIT: I have confirmed that this works fine on vanilla GCC. On MCHP XC32 I can do this and then it compiles fine

#define CONFIG_FILE "demo_config.h"
#include CONFIG_FILE

It seems like when I pass in the filename via the command line something weird and unexpected is happening ...

I used a trick to print the value and the filename is ending up in the code correctly it seems ...

#define XSTR(x) STR(x)
#define STR(x) #x

#pragma message "The include is " XSTR(CONFIG_FILE)
    #include CONFIG_FILE

This will produce:

#pragma message: The include is "demo_config.h"

error: #include expects "FILENAME" or <FILENAME>


Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • Member

The weird thing is that printing out the value in the file like I did it includes the quotes though. 

When I played around with the command line I eventually managed to get it to work by passing in something like:


The disappointing thing for me was that passing in the exact same thing that I am passing to GCC does not seem to work with the Microchip version.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.


  • Create New...