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

Re: PPlay Release



Jan Ekholm wrote:

>>>>BTW: egcs 1.1.x still has problems with template functions
>>>
>>>But it can at least link them without problems. I know there are some
>>
>>Only if you use them in the same source file. If you want to implement them
>>in one file and use them in another (both compiled seperately), you'd need
>>to use the "export" keyword - which egcs doesn't support yet.
>
>Hmm? I don't get that. So you mean that I can't create a templatized
>'btree' in the files 'btree.h' and 'btree.cpp' and then use it in a file
>'use_btree.cpp' by just including 'btree.h' and linking in 'btree.o'?
>Weird. I do this all the time with Zombie. Please don't tell the compiler
>that it really can't do what it does... :-)

That's a template *class*, not a template *function*. I *think* there's a
difference.

I checked it again. It doesn't work.

--------------- xx.h
#ifndef XX_H
#define XX_H

template <class c> void print (c C);

#endif
---------------

--------------- xx.cc
#include <iostream>
#include "xx.h"

template <class c> void print (c C)
{
	cout << C;
}
---------------

--------------- main.cc
#include "xx.h"

int main (void)
{
	int MyVal = 200;

	print (MyVal);

	return 0;
}
---------------

g++ -c xx.cc
g++ -c main.cc
g++ xx.o main.o -o main
  main.o: In function `main':
  main.o(.text+0x12): undefined reference to `void print<int>(int)'
  collect2: ld returned 1 exit status



	Christian

--

Drive A: not responding...Formatting C: instead