On Nov 29, 2:26*am, James Kanze <james.ka...@gmail.com> wrote:
> On Nov 29, 1:03*am, NvrBst <nvr...@gmail.com> wrote:
>
> > This seems like a very basic question but I can't seem to
> > google the answer. *Should the .H and .CPP always be in the
> > same directory? *Or is it safe to put all my ".h" file in a
> > "inc" folder, and all my .cpp files in a "src" folder?
>
> There's no real rule. *Different projects organize things in
> different ways.
>
> > MSDN says (#include"") "This form instructs the preprocessor
> > to look for include files in the same directory of the file
> > that contains the #include statement, and then in the
> > directories of any files that include (#include) that file.".
> > How is the 2nd part of the statment possible?
>
> In what way shouldn't it be possible? *(Note that not all
> compilers support that second part.)
>
> >*For example
> > MyProj1/inc/*.h
> > MyProj1/src/*.cpp
>
> > MyProj2/inc/*.h
> > MyProj2/inc/*.cpp
> > Say a file in MyProj2 wants to include something in the "MyProj1/inc"
> > folder, it'd go "include <MyProj1File.h>" and then add * -I"path/
> > MyProj1/inc" *to the command line, would I also have to add the source
> > directory * -I"path/MyProj2/src"?
>
> First, you'd probably want to use ``#include "MyProj1File.h"'';
> the <...> form is for "system" headers. *And why would you have
> to add the source directory to the list? *You're not including
> anything from it. *(Also, I'm very dubious about including a
> header from another project. *Normally, you would export the
> project at some point when it is stable, and include the header
> from where ever you exported it to.)
>
> > This is just a cosmetic thing, I'm a little new to C++ and
> > wanted to know if I'd be laughed out of the room by having
> > seperate "inc" and "src" folders,
>
> Certainly not. *It seems to be a common organization for
> freeware.
>
> > and also how a header file finds it's source file (aka just
> > magic, the -I flag, or something else).
>
> The header file doesn't find its source file. *It has no need of
> the source file. *The linker will need to find the corresponding
> library, of course, so you'll have to provide the appropriate
> flags there.
>
> --
> James Kanze (GABI Software) * * * * * * email:james.ka...@gmail.com
> Conseils en informatique orientée objet/
> * * * * * * * * * *Beratung in objektorientierter Datenverarbeitung
> 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Thanks, I understand it better now -headers don't need their source
files-; that was the part that was tripping me up.

So I just have
to find the "-I" equavalent(maybe same) flag for the linker (pointing
to the .o files). Thanks again.