Article View: comp.std.c++
Article #2424Header file inclusion and multiple directories
From: Eric Biederman
Date: Sat, 04 Nov 1995 09:40
Date: Sat, 04 Nov 1995 09:40
46 lines
1748 bytes
1748 bytes
Consider a project that spans several directories. In particular, let's suppose it has the files project/d1/base.h, project/d1/derived.h, and project/d2/main.cc. Here are some code fragments. [snip] So my challenge: can anyone think of an acceptable replacement for "The named source file is searched for in an implementation-defined manner" that would provide a bit more of a guarantee of reasonable behavior? I think I can, I'll let you be the judge. Create a header file that you know you can include, in it have something line #define STR__(X) #X #define STR(X) STR__(X) #define CAT__(A,B) A##B #define CAT(A,B) CAT__(A,B) #define ROOT_DIR /home/someone/project/ #define NAME(X) STR(CAT(ROOT_DIR,X)) #define BASE NAME(d1/base.h) #define DERIVED NAME(d2/derived.h) then say something like #include "includes.h" #include DERIVED Then all you have to have is includes.h simply reachable from every file, say a copy in every directory and it should work fine. Of course for a really strange system the includes.h file needs to be seriously changed but nothing else does. Hope that helps Matt, Eric --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<199511040410.WAA12178@cse.unl.edu>Path:
arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!MattShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.mindlink.net!agate!agate!Matt From: ebiederm@cse.unl.edu (Eric Biederman) Newsgroups: comp.std.c++ Subject: Header file inclusion and multiple directories Date: 04 Nov 1995 09:40:46 GMT Organization: <none> Approved: Matt@Austern Message-ID: <199511040410.WAA12178@cse.unl.edu> NNTP-Posting-Host: austern.hip.berkeley.edu