Extensionless headers
Benjamin Kosnik
bkoz@redhat.com
Thu Jan 10 21:26:00 GMT 2002
Posted by request. This looks fine to me.
----
Benjamin asked me to write up a summary and post a patch for what I've
been doing locally. Jason's summary (ending with "Why not just keep
the extension?") pretty much speaks for me and, I think, Nathan. I'll
list the points I had already written before reading Jason's concise
paragraph:
- Users of tools such as find and grep used to be able to use *.h or
std_*.h; they must now either list all the headers explicitly, or
recurse into a directory and hope/assume/ensure that nothing else but
standard headers are in that directory.
- Some tools such as editors and file managers which change their
behavior based on file extension now break (e.g., syntax coloring or
file-program associations). (Vim and Emacs and Konqueror and
company, which all examine file contents, notwithstanding.)
- If the user happens to be editing a copy of an extensionless header
in a particular build dir, and makes a typo when invoking make, and
then interrupts the build, some versions of GNU Make may or may not
delete the modified extensionless header. This can be (politely)
categorized as a corner case, but hey.
This patch only addresses the std/ headers; I am violently apathetic
about what we call the ext/ headers. :-)
In the source tree, std/foo is renamed to std/std_foo.h. None of the
files anywhere need to be edited to take advantage of this change.
(If we don't like "std_" as a prefix, okay, but just foo.h would be
dangerously confusing.)
In the build dir's staging include directory, when we create
symlinks/copies of the std headers, we use their official names
locally, instead of their real names. Everything else in the build
and testsuite works via the staging directory; this is why we don't
need to edit any source files.
Below is the patch to include/Makefile.am. The actual patch to rename
all the files would just be a gigabyte of diffs against /dev/null, but
here's how I did it locally:
cd include/std
for i in [a-z]*; do
mv $i std_${i}.h
cvs remove $i
cvs add -m 'Renamed file.' std_${i}.h
done
Then apply the following, and "cd ../.. ; automake include/Makefile"
to regenerate.
Index: Makefile.am
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.20
diff -u -3 -r1.20 Makefile.am
--- Makefile.am 4 Jan 2002 21:27:30 -0000 1.20
+++ Makefile.am 10 Jan 2002 20:32:01 -0000
@@ -185,35 +185,35 @@
std_srcdir = ${glibcpp_srcdir}/include/std
std_builddir = ./
std_headers = \
- ${std_srcdir}/algorithm \
- ${std_srcdir}/bitset \
- ${std_srcdir}/complex \
- ${std_srcdir}/deque \
- ${std_srcdir}/fstream \
- ${std_srcdir}/functional \
- ${std_srcdir}/iomanip \
- ${std_srcdir}/ios \
- ${std_srcdir}/iosfwd \
- ${std_srcdir}/iostream \
- ${std_srcdir}/istream \
- ${std_srcdir}/iterator \
- ${std_srcdir}/limits \
- ${std_srcdir}/list \
- ${std_srcdir}/locale \
- ${std_srcdir}/map \
- ${std_srcdir}/memory \
- ${std_srcdir}/numeric \
- ${std_srcdir}/ostream \
- ${std_srcdir}/queue \
- ${std_srcdir}/set \
- ${std_srcdir}/sstream \
- ${std_srcdir}/stack \
- ${std_srcdir}/stdexcept \
- ${std_srcdir}/streambuf \
- ${std_srcdir}/string \
- ${std_srcdir}/utility \
- ${std_srcdir}/valarray \
- ${std_srcdir}/vector
+ ${std_srcdir}/std_algorithm.h \
+ ${std_srcdir}/std_bitset.h \
+ ${std_srcdir}/std_complex.h \
+ ${std_srcdir}/std_deque.h \
+ ${std_srcdir}/std_fstream.h \
+ ${std_srcdir}/std_functional.h \
+ ${std_srcdir}/std_iomanip.h \
+ ${std_srcdir}/std_ios.h \
+ ${std_srcdir}/std_iosfwd.h \
+ ${std_srcdir}/std_iostream.h \
+ ${std_srcdir}/std_istream.h \
+ ${std_srcdir}/std_iterator.h \
+ ${std_srcdir}/std_limits.h \
+ ${std_srcdir}/std_list.h \
+ ${std_srcdir}/std_locale.h \
+ ${std_srcdir}/std_map.h \
+ ${std_srcdir}/std_memory.h \
+ ${std_srcdir}/std_numeric.h \
+ ${std_srcdir}/std_ostream.h \
+ ${std_srcdir}/std_queue.h \
+ ${std_srcdir}/std_set.h \
+ ${std_srcdir}/std_sstream.h \
+ ${std_srcdir}/std_stack.h \
+ ${std_srcdir}/std_stdexcept.h \
+ ${std_srcdir}/std_streambuf.h \
+ ${std_srcdir}/std_string.h \
+ ${std_srcdir}/std_utility.h \
+ ${std_srcdir}/std_valarray.h \
+ ${std_srcdir}/std_vector.h
target_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
target_builddir = ./${target_alias}/bits
@@ -240,11 +240,16 @@
# Here are the rules for building the headers
all-local: ${target_builddir}/c++config.h ${allstamps}
+# This rule is slightly different, in that we must change the name of the
+# local file from std_foo.h to foo.
stamp-std: ${std_headers}
@if [ ! -d "${std_builddir}" ]; then \
mkdir -p ${std_builddir} ;\
fi ;\
- (cd ${std_builddir} && @LN_S@ $? .) ;\
+ (cd ${std_builddir} && for h in $?; do \
+ official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\
+ @LN_S@ $$h ./$${official_name} ;\
+ done) ;\
echo `date` > stamp-std
stamp-bits: ${bits_headers}
More information about the Libstdc++
mailing list