1

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
tyler
  • 1,273
  • 2
  • 16
  • 40
  • 3
    Sounds like you are missing a `-DFILE_PATH="hal/micro/config.h" compiler flag. – Suedocode Feb 06 '15 at 18:02
  • Are you sure it is predefined? Check it with `#ifdef` – Eugene Sh. Feb 06 '15 at 18:04
  • 2
    Use your command-line for compiling that, and combine with advice from here: http://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines Is `FILE_PATH` really defined as it should be? Not perhaps missing the string-markers and unescaped? – Deduplicator Feb 06 '15 at 18:06
  • I'm at work and wont be able to test for 2 hours. I'll post back with my results shortly. – tyler Feb 06 '15 at 18:08
  • http://ideone.com/U5fj0Z you probably have a typo. In c++11, it's allowed per [cpp.include] 16.2.4 – stefan Feb 06 '15 at 18:08
  • @Aggieboy - See additional details. – tyler Feb 06 '15 at 21:47
  • @stefan - I don't think thats the case here. – tyler Feb 06 '15 at 21:48
  • @EugeneSh. - I tried this see additional details for feedback – tyler Feb 06 '15 at 21:48
  • @Deduplicator - I am not exactly sure how to do this...I updated the question with additional info. I will be researching how to accomplish this. – tyler Feb 06 '15 at 21:49
  • 1
    Maybe the IDE does not correctly escape the parameters. Could you try escaping the quotes? You can also try placing `PLATFORM_HEADER` somewhere in the code and see what the compiler would tell you it sees. – StenSoft Feb 06 '15 at 21:52
  • @StenSoft it worked! Write that in an answer so I can give you some credit. – tyler Feb 06 '15 at 21:59

1 Answers1

1

@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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • ([Answered in the comments and converted to a community wiki answer.](http://meta.stackoverflow.com/questions/251597/question-with-no-answers-but-issue-solved-in-the-comments)) – Brian Tompsett - 汤莱恩 May 23 '16 at 20:19