home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:16234 comp.std.c++:1560 gnu.g++.help:1431
- Newsgroups: comp.lang.c++,comp.std.c++,gnu.g++.help
- Path: sparky!uunet!utcsri!newsflash.concordia.ca!garrot.DMI.USherb.CA!garrot!dechc00
- From: dechc00@tohi.DMI.USherb.Ca (CHRISTIAN DECHAMPLAIN)
- Subject: Where do templates go?
- Message-ID: <DECHC00.92Nov13122503@tohi.DMI.USherb.Ca>
- Lines: 33
- Sender: usenet@DMI.USherb.CA (Pour courrier Usenet)
- Nntp-Posting-Host: tohi
- Organization: Universite de Sherbrooke -- departement de Mathematiques et
- d'Informatique
- Date: Fri, 13 Nov 1992 17:25:06 GMT
-
-
- Thanks to those who answered my original question.
-
- With g++ it seems that every implamentation file with a template declaration
- needs to see the template functions definitions in order to produce object
- code for the particular template arguments. It means that your template code
- has to be in the include file. It also seems to mean that the #pragmas
- interface and implementation won't behave properly in this case because it
- introduces multiply defined simbols.
-
- At least I can't find a way to make them work properly with the way I tried
- to use them. What I do now is include the .h and .cc files in the modules
- I need templates expanded and just include the .h file in those modules
- where the template functions are refered to. I just don't put any #pragmas
- in the .h and .cc files with template definitions.
-
- Do all C++ compilers work this way? Will I get multiply defined simbols if
- I try to compile my source files with a compiler that can 'link' templates?
- Does it mean that no template librairies can exist? Does it mean that the
- code will always get duplicated when templates are used?
-
- Could there be a #define __LINKABLE_TEMPLATES that would permit us to develop
- future-compilable code? At least with g++.
- Wouldn't a #pragma expand_template "file.cc" be nice.
- (see page 347 of the ARM)
-
- Thanks for any answer.
-
- --
- Christian Dechamplain|
- (819) 563-8951 |
- dechc00@dmi.usherb.ca|
- ----------------------
-