Search code examples
cc-preprocessorheader-filescode-composer

How to predefine header file path in a project


I am trying to use the following method to include a project header file:

#include FILE_PATH

Where FILE_PATH is defined as the file to be included.

The project compiles without errors if FILE_PATH is include as:

#define FILE_PATH "hal/micro/config.h"
#include FILE_PATH

But if FILE_PATH is pre-defined as a compiler define option inside the project options, then building the project returns the following error:

Error #13: Expected a file name

The development software being used is Code Composer Studio version 6.

What am I missing here to pre-define the header file path in a project?

Additional Details:

I am in the process of converting a working project from the IAR embedded workbench IDE to Code Composer Studio. The Pre-define NAME (--define, -D) shown in the picture below are mostly identical to how they were in the IAR project. enter image description here

The pre-define name boxed in red is currently the cause of the error, but this could occur with any of the other defines with file pathnames.

enter image description here

I have tried the suggestion of using the #ifdef statement to at least verify that PLATFORM_HEADER is actually defined and it does seem to be defined. I also checked for typos and there doesn't appear to be any noticeable typos.

enter image description here

The key reason for wanting to go with the pre-defined macro approach is to avoid individually making changes to numerous files affected by this error.

enter image description here

I still have not yet tried a command line compile, since I need to reference the manual on how to do so, but I will try as soon as I figure it out.


Solution

  • @StenSoft wrote:

    The IDE does not correctly escape the parameters. You should escape the quotes. You can also try placing PLATFORM_HEADER somewhere in the code and see what the compiler would tell you it sees.