From -8755346237577549412
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,6949d6499f54708
X-Google-Attributes: gidf78e5,public
From: fjh@mundil.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Stupid Preprocessor Question
Date: 1995/05/20
Message-ID: <9514102.2925@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 102964188
sender: news@cs.mu.OZ.AU (CS-Usenet)
references: <41d7cb$03325.3a@rd.surface.com> <527cb$10181a.1ab@rd.surface.com> <3p4nja$mnp@hustle.rahul.net>
organization: Computer Science, University of Melbourne, Australia
newsgroups: comp.std.c++

Miles B. Whitener <mbw@surface.com> wrote:

>If I have two header files, a.h and b.h, and they are both
>in ../../Common/ (relative to my .C or .cpp file), and I want to include
>b.h from a.h, should a.h say
>  #include "b.h"
>or should it say
>  #include "../../Common/b.h"
>?
>
>Borland 4.02 seems to require the latter, which seems insane, while 
>MS 2.1a likes the former, which seems correct to me.  But my
>code has to compile under both and I just wish they agreed.

I agree that the latter is somewhat insane, since the relative path
depends on the location of the file you are compiling.
However, another alternative is to say

	#include "Common/b.h"

and compile with "-I ../..".  This alternative has the advantage that
you only need one "-I" option for each package you are using, and 
the #include lines remain constant no matter which directory you
are compiling from - only the -I option need change.

I agree with RFG that it is a pity this area has not been standardized.

-- 
Fergus Henderson                       | I'll forgive even GNU emacs as
fjh@cs.mu.oz.au                        | long as gcc is available ;-)
http://www.cs.mu.oz.au/~fjh            |             - Linus Torvalds



