Re: #include files from another directory

From: David Fisher (nospam_at_nospam.nospam.nospam)
Date: 01/15/04


Date: Thu, 15 Jan 2004 16:50:48 +1100


"Christopher" <anon@nospam.net> wrote:

> What is the syntax for including files from another directory? In my case
I
> want to include a file called "error.h" which lies in a directory called
> "support" which is a directory inside the (project/solution/source or
> whatever you may call it) directory.
>
> it looks like this (hope the ascii comes out)
> dir engine_x
> ....dir support
> .............file error.h
> .............file error.cpp
> ....file main.cpp

There are a few options:

1. Your C++ compiler probably has a flag to let you specify where to look
for include files other than the current directory. For gcc the flag is
"-I"; for Visual C++ 6.0, look in Tools -> Options -> Directories.

2. You can #include a file in a relative directory, eg. #include
"engine_x/support/error.h" (assuming the current directory is the one below
engine_x). Note that all known include directories are searched, so you
could so something like adding "engine_x" to the include directory list (as
above) and then say #include "support/error.h"

3. (Never do this !) Use the absolute path name, eg. #include
"/home/users/fred/engine_x/support/error.h" This is very bad, because the
code can never be moved around or given to someone else.

BTW. If possible, it might be a good idea to rename "error.h" - it is a
common name, and it might get confusing if the wrong header is included.

David F



Relevant Pages

  • Re: Telephone # for technical support via long distance charges??
    ... > rest of the flag information does (a fact which renders this feature ... > onto this feature and it's been a god-send in many contracts. ... > charge up-front via credit card? ... I suggest that you go straight to the source...call Microsoft's main support ...
    (microsoft.public.outlook)
  • Re: Telephone # for technical support via long distance charges??
    ... > rest of the flag information does (a fact which renders this feature ... > onto this feature and it's been a god-send in many contracts. ... > charge up-front via credit card? ... I suggest that you go straight to the source...call Microsoft's main support ...
    (microsoft.public.outlook.program_vba)
  • Re: Telephone # for technical support via long distance charges??
    ... > rest of the flag information does (a fact which renders this feature ... > onto this feature and it's been a god-send in many contracts. ... > charge up-front via credit card? ... I suggest that you go straight to the source...call Microsoft's main support ...
    (microsoft.public.outlook.program_addins)
  • Re: Telephone # for technical support via long distance charges??
    ... > rest of the flag information does (a fact which renders this feature ... > onto this feature and it's been a god-send in many contracts. ... > charge up-front via credit card? ... I suggest that you go straight to the source...call Microsoft's main support ...
    (microsoft.public.outlook.thirdpartyutil)
  • Re: On re / regex replacement
    ... If I can undestand the ASCII flag, ASCII being the "lingua franca" of ... compliant shoud be locale independent and a locale ... depedency means a loss of unicode compliance. ... the NEW flag. ...
    (comp.lang.python)