From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,a70b277fb66062ec X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-03-16 10:02:32 PST Newsgroups: comp.unix.osf.osf1 Path: bga.com!news.sprintlink.net!EU.net!CERN.ch!rscernix!danpop From: danpop@cernapo.cern.ch (Dan Pop) Subject: Re: cpp bug? X-Nntp-Posting-Host: ues5.cern.ch Message-ID: Sender: news@news.cern.ch (USENET News System) Organization: CERN European Lab for Particle Physics X-Newsreader: NN version 6.5.0 #9 (NOV) References: <3k4mop$nvi@lyra.csx.cam.ac.uk> Date: Thu, 16 Mar 1995 17:44:03 GMT In <3k4mop$nvi@lyra.csx.cam.ac.uk> jkb@mrc-lmb.cam.ac.uk (James Bonfield) writes: >I have a C file called (eg) /X/prog.c that includes "inc.h". >Now there's an "inc.h" in my current directory (which is not /X) and also in >the /X directory. My current "inc.h" is a different version than the one in >/X. Now the question is how do I compile prog.c to include my own inc.h? inc.h >is included using "inc.h" rather than . > >The most natural thing is: > >cc -I. -c /X/prog.c -o prog.o > >However this includes /X/inc.h still. So I then tried disabling the standard >include path and explicitly setting things: > >cc -I -I/usr/include -I`pwd` /X/prog.c -o prog.o > >Nope - it still picks up /X/inc.h. I've tried c89 and cc -migrate too. This is >getting _REALLY_ annoying. I finally figured that 'gcc -I. -I-' works, but I'd >rather use cc than gcc (as it means recompiling gcc to bring myself vaguely up >to date). It's not a bug, it's the documented behaviour. From the cpp man page: -Idir Change the algorithm for searching for #include files whose names do not begin with / to look in dir before looking in the direc- tories on the standard list. Thus, #include files whose names are enclosed in "" will be searched for first in the directory of the ifile argument, then in directories named in -I options, and last in directories on a standard list. For #include files whose names are enclosed in <> , the directory of the ifile argument is not searched. > >Do I need to use instead of "inc.h"? This will be a real pain if so as >we're actually talking about in excess of 300 include files that are doubtless >included many more times. Apparently, this is the only solution, if you want to avoid gcc. > >It seems to be a bug of the cpp to me that it is impossible to override the >explicit search of the local directory when looking for include files. Is >there any solution to this other than copying (or symlinking) over all the >source from /X to .? Seems a bit drastic and annoying. It's not a bug, it's a feature :-) You should have thought about this problem when you developed the code. The semantics of "" and <> in Unix are pretty standard, this is not something specific to OSF/1, so you have no chance to convince DEC to change their cpp. If you needed the semantics of <>, you should have used <> in the first place. Dan -- Dan Pop CERN, CN Division Email: danpop@cernapo.cern.ch Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland