0

So, I'm starting out my first project in VS2010, and I see that I can drag and drop files into the project tree, lovely. However, this doesn't resolve missing includes? I'm assuming it's not good form to put all the header files in the same folder as the source code files. Yes, I know there's such a thing as an include environment variable, but surely I'm not expected to store all the headers for every project I ever do in there, until the end of time?

Clearly I'm misunderstanding something. Please be gentle, new to C++ as well.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
jamesson
  • 317
  • 3
  • 18
  • The linked question should answer your question adequately. – N_A Apr 21 '12 at 23:28
  • That does indeed explain it quite well. However, is there any logic here? Wouldn't it make sense put the header files in the header folder once they are added to the project? – jamesson Apr 21 '12 at 23:32
  • See my answer below. The include directories are used for things like library headers. Typically you would use option #1 from the linked question. – N_A Apr 21 '12 at 23:35

1 Answers1

1

Are you using angle brackets instead of quotes?

The preprocessor in VS 2010 looks into the current dir only if the quoted include syntax is used (e.g #include "whatever.h"). Using angle brackets (e.g #include ) omits the current dir.

Quote from here.

If you need subdirectories of the current directory you can specify them in the include statement. I.e. #include "subfolder/header.h.

See here.

Community
  • 1
  • 1
N_A
  • 19,799
  • 4
  • 52
  • 98
  • What do they mean by "opened"? Opened at compiletime? If so, is it possible for code hinting to be unable to find the referenced header even though the compiler will? Understood re linked answer, but then how shall I work with projects based on great big libraries? – jamesson Apr 21 '12 at 23:38
  • If you're working with projects based on libraries then you need to use the project properties path or the general VS path. From where are you referencing '"opened"'. – N_A Apr 21 '12 at 23:39
  • Microsoft site "In the directories of any previously opened include files" – jamesson Apr 21 '12 at 23:41
  • Oh, that means compile time. If code hinting can find it then the compiler can find it, otherwise there is a bug in VS. (has happened before...) – N_A Apr 21 '12 at 23:42