0

I'm sure there is a really simple solution to this.

I'm trying to include a header file. I have added the include directory. when I include with quotes the new feature in vs2010 now shows me that it can 'see' the file I want to include and the tool tip references it in the correct directory.

however I get a red underscore under the #include indicating there is a problem and the project won't build because it cannot include the file.

I can build by adding the full relative path but this is a bit messy.

so in summary

#include "myfile.h"  FAILS
#include "../../includes/myfile.h" WORKS

any ideas?

1
  • What is the absolute path of your file and what are your include directories? Commented Oct 15, 2011 at 11:19

2 Answers 2

2

You have to add ../../includes in the following field:

Project Properties > C/C++ > General > Additional Include Directories

For more details visit the appropriate MSDN page.

Sign up to request clarification or add additional context in comments.

1 Comment

There is not enough information to help you further. Try to create a minimal project that exhibits faulty behavior. After that make this minimal project more and more similar to original project. At one point you will find a problem.
0

If

#include "myfile.h"

fails, but

#include "../../includes/myfile.h"

works, that means you don't have the include directories in your path. Say you have your structure like this:

/project
   /src
      myfile.cpp   -> myfile.h included here
   /include
      /dir1
          myfile.h

You need to add to your include directories ./include/dir1/, not just ./project or ./include.

Using <...> instead of "..." just tells the compiler to first look in the system include directories first, so that wouldn't be of much help. Answers stating this are wrong. Usually, you would use <...> for headers like string or vector and "..." type includes for your own headers.

1 Comment

I had added the include dirs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.