*** MOVED ***

NOTE: I have merged the contents of this blog with my web-site. I will not be updating this blog any more.

2005-09-13

C++ Madness

Compile the following program with "g++ -fno-implicit-templates foo.cpp" and admire the error message that you get. Just how is a mortal programmer supposed to make sense of this?

#include <string>
#include <map>
using namespace std;
int main( void)
{
map<string,string> foo;
return 0;
}

The example might look bogus, but consider this: you have been told that explicit template instantiations can some times considerably speed up your build process, not to mention save space used up by the object files, so you begin by creating an explicit instantiation file that you try to populate with template instantiations that are actually used by your program. You compile all other source files using "-fno-implicit-templates", but not the one special file. If you have not caught all template instantiations however, you will hit the monster of an error message that I sought to show per missing template instantiation. You are supposed to then figure out from these error messages which of the template instantiations you have missed out. Should anyone be surprised if you lose all hope at this point and just ditch the idea?

(Originally posted on Advogato.)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.