Suggestions on renaming headers (was Re: [PATCH] Update backward/algo.h)

Phil Edwards pedwards@disaster.jaj.com
Thu Jan 3 11:53:00 GMT 2002


On Thu, Jan 03, 2002 at 07:19:33AM +0000, Nathan Myers wrote:
> Suppose you have a file foo.cc that includes <foo>.  Suppose further 
> that you have been experimenting with changes in header <foo>, so you 
> have copied it into the local directory, and added "-I." to your 
> CXXFLAGS to pick up your local version in place of the one off in 
> src_dir.  Now, you mean to type "make foo.o", but you type "make foo" 
> by accident. You get a foo.o all right, but then the link fails (no 
> control-C needed) and make deletes the implicit target foo, which
> happens also to be your header file.

Ick.


> Foremost among these is Make's ".o.:" implicit rule, which is 
> useless to us in any case (it invokes $(CC)).

Like you say, this should be easy to solve.  Clearing and resetting the
.SUFFIXES pseudotarget should help in most cases.  Listing all the headers in
a .PRECIOUS rule might help.  (The multiple makefiles make this interesting.)

Ideally we would arrange for Make to be invoked with '-r' to clear all
the implicit rules.  This option is common between Linux and Solaris,
but I don't know if it's POSIX or just SysV.  (Loren, does BSD have this?)
Nor can I think of any way offhand to arrange this.


> The naming
> convention problem is a consequence of the failure to implement the 
> preprocessor in the way the committee had expected, which was to 
> alter suffixless header names before lookup.

That would have been... odd.


> It may be that recent changes in Make, coupled with great care in 
> where files are edited, can substitute for a sound file naming 
> convention.

Well, I think that after moving the headers we'll still have a sound
naming convention.

The care required shouldn't be very great:

    Don't copy headers into the build dir, and then use -I. to find them.

We already have a good system in place to find headers; developers should
be using it.  Specifically:

1)  Edit the header in the source directory.  Make a backup copy first,
    or not, either way you can use CVS to look for differences and undo
    your changes.

2)  Normally we symlink from $builddir/include/foo into $srcdir.  A user
    can delete the symlink and copy the file instead.  Then the header in
    the staging area can be edited.

    This is protected from "the care required" problem, because the rule
    to "build" the staging headers doesn't do anything like deleting files.


My opinion:  we should move the headers /and/ add some special targets to
the makefiles, like .PRECIOUS and/or .SUFFIXES.  Someone with wider Make
experience than I will need to help with those targets.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams



More information about the Libstdc++ mailing list