Jump to content
 
  • 0

Preprocessor defines for XC32 used to select include file


Orunmila
 Share

Question

  • 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 

-DCONFIG_FILE=\"demo_config.h\"

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

#undef CONFIG_FILE
#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)
#ifdef CONFIG_FILE
    #include CONFIG_FILE
#endif

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

  • 0
  • 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:

-D'CONFIG_FILE=\\\"demo_config.h\\\"'

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

 


×
×
  • Create New...