Re: Problem with class operators.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kristian,
  Are you asking if there is a way for the compiler to make note of aninternal linkage and instantiation in one file and translate that toanother file?
  I think that you'll find scoping rules will limit this.  Thedeclaration and sometimes definition needs to be visible at the timeof instantiation.
  A basic example is section 14.7 paragraph 6 of the specification:
If an implicit instantiation of a class template specialization isrequired and the template is declared but notdefined, the program is ill-formed. 
[Example:template<class T> class X;
X<char> ch; // error: definition of X required—end example]
Paragraph 3 gives examples for required method instantiations.
corey
On 7/25/05, Kristian Kratzenstein <kristian.kratzenstein@xxxxxxxxxxx> wrote:> Hi Eljay,> > Nearly as I thought. But : When the template method / function is used in> the related cpp file, then the Linker could link from other files to the> same function (with same type).> Therefor I use a dummyfunction.> > The problem now is, that CW and VC preserve the methods during compiling.> gcc now optimize them away (small, like GetBuffer or so), so they run in> the file, but cannot be linked.> > So, is there a way to get those methods preserved, so I could link to them> ?> > I know, the best is : into the Headers. But I made template classes> (some), which are based on each other. Cause the size, I would like to> have them in cpp / h file. Also this looks more clean.> > Kind regards> > Eljay Love-Jensen <eljay@xxxxxxxxx> on Montag, 25. Juli 2005 at 17:32> +0100 wrote:> >Hi Kristian,> >> >Non-specialized template functions and methods need to be defined in the> >header file which declares them.> >> >Otherwise they are only visible to the translation unit in which they are> >defined.> >> >HTH,> >--Eljay> >> >> >> > > > --------------------------------------------> Kristian Kratzenstein> Gettorf> > Kristian.Kratzenstein@xxxxxxxxxxx> --------------------------------------------> > >

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux