From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,7d90b6304214be32,start X-Google-Attributes: gidfee84,public From: Snow Wang Subject: Problem with template instantiation using cxx 6.0 compiler Date: 1998/09/11 Message-ID: <35F97156.D9D162DA@us.ibm.com>#1/1 X-Deja-AN: 390196963 Content-Transfer-Encoding: 7bit Organization: IBM Microelectronics Division Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 I need to build an application that uses template on DEC OSF 4 using cxx 6.0 compiler. In addition to the template classes we declared, ObjectSpace STL is used. To avoid code bloat, we want each template class to be instantiated just once, in the repository, instead of being instantiated in every translation unit that needs that template class. cxx 6.0 compiler does template instantiation at compile time (automatic template instantiation) instead of at linking time, and a repository can be specified by -ptr dir_path to store the instantiation. The documentation claims that when translation unit is compiled and template class is encountered, it looks into the repository to see if it has been instantiated. If so, it uses the one in the repository, otherwise it instantiates it in the repository. I tried building it with -ptr flag, but I found instantiation was done both in the repository and in all the object files that need that template class, causing the linker to complain that some template classes are multiply defined. But if I build it with -nopt flag to disable the automatic template instantiation, no instantiation will be done at all. I wonder if anybody had problems like this before and certainly will appreciate it if you can tell me how to do it right. Thanks! Snow Wang