home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16234 < prev    next >
Encoding:
Internet Message Format  |  1992-11-14  |  1.9 KB

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