Controlling "-cwd include" option in Eclipse

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Controlling "-cwd include" option in Eclipse

Jump to solution
750 Views
avm
Contributor I

Targeting Kinetis using CodeWarrior 10.5, I'm having trouble with the system include paths. If I try to #include <somefile.h> using angle brackets, I would expect it to only search the include paths in the system and system recursive path lists. However, if somefile.h happens to exist in the current directory, it always finds that local file. I wouldn't be too surprised for that to happen if the #include statement uses quotes, but I don't think it should do it if using angle brackets.

 

Looking at the project properties, in the "All options" box which shows the command line options, I see that the "-cwd include" option is selected. According to the documents, this says to search the directory of the referencing file first. I highly suspect that this is my problem. I think I need to use the "-cwd explicit" option to get the behavior I want which is:

  • #include "somefile.h" should search my user and user recursive folders first, then the system and system recursive folders.
  • #include <somefile.h> should only search the system and system recursive folders and not look in any of the user include paths.
  • I don't care about the current folder: all my folders are in the various include search paths. Just using user/system or system paths is enough for me.

 

Looking through all of the project configuration options, I don't see anywhere that the "-cwd include" can be controlled. It looks like it might be hard-coded somehow?

 

How do I change the project options so that it uses "-cwd explicit"? Or, how do I get it to not look in the current directory when using a #include with angle brackets?

Labels (1)
0 Kudos
1 Solution
555 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Avm

Are you using GCC compiler?  It works in a different manner for searching head file.

It will look for headers requested with #include <file> in:

-Idir1 -Idir2 ...
/usr/local/include
libdir/gcc/<target>/<version>/include
/usr/<target>/include
/usr/include

All the directories named by -I are searched. So please check how you add the directories for this option in your project:

compiler option.png

include.png

For details, you may review:

https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art026

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
556 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Avm

Are you using GCC compiler?  It works in a different manner for searching head file.

It will look for headers requested with #include <file> in:

-Idir1 -Idir2 ...
/usr/local/include
libdir/gcc/<target>/<version>/include
/usr/<target>/include
/usr/include

All the directories named by -I are searched. So please check how you add the directories for this option in your project:

compiler option.png

include.png

For details, you may review:

https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art026

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos