[LC++]Generic programming vs OO inheritance

Jack Lloyd lloyd at acm.jhu.edu
Tue Aug 21 02:32:58 UTC 2001


> My biggest grief with gcc C++ templates is the lack of support for export.

Nobody supports export. I actually belive that to be a literal statement;
absolutely no existing compiler from any vendor supports export. If there
is one, let me know, I'm curious who will have it first.

> As it is now, I have to include the routine implementations from header
> files. In a big project, with widely used template classes, this means
> that a small change to the implementation of some template class routine
> implementation results in recompilation of practically the whole system.
> This is extremely inconvenient.

A nice workaround, and makes things easier when compilers do have export:

  1) Cut out all the 'real' code (code that would go in a source file if it
could).

  2) Put it into another file (I call them .icc, for included CC, but
whatever works for you)

  3) Add a line at the bottom of your stripped down header including the
icc file (with header guards, etc, as needed)

  4) Modify your build process to ignore icc files. This could be easy or
hard, depending on what you're using.

But now, anyway: your headers are cleaner, since there isn't all the extra
code mucking them up; once compilers support export you can simply rename
the icc file to cpp (or whatever your prefered suffix is), and add in
export declarations (which should be a simple search and replace); and it's
at least possible to prevent simple typo fixes from forcing a complete
recompile.

-J




More information about the tuxCPProgramming mailing list