🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Eric Biederman Sat, 04 Nov 1995 09:40
Header file inclusion and multiple directories
#2424
Author: Eric Biederman
Date: Sat, 04 Nov 1995 09:40
46 lines
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. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads