Excuse for my inaccurasy in the previous E-mail. Anyway i have obtained from compiler the following log: --------------------Configuration: prova2 - Debug-------------------- Compiling... prova8.cpp D:\Documenti\prova2\prova8.cpp: In function `void my_fun2() [with T = float]': D:\Documenti\prova2\prova8.cpp:9: instantiated from `void my_fun1() [with T = float]' D:\Documenti\prova2\prova8.cpp:19: instantiated from here D:\Documenti\prova2\prova8.cpp:14: warning: unused variable `float prova' prova8.o - 2 error(s), 1 warning(s) greetings from pinzi > Thank you for your reply. > I have modify the program in the following way: > > #include > using namespace std; > > template void my_fun2(); > > template void > my_fun1(){ > my_fun2(); > }; > > template void > my_fun2(){ > T prova=1234; > }; > > int main() > { > my_fun1(); > return 0; > }; > > But now the compiler tell me that there is an error in my_fun2. > Please help me. > > the code above should be correct (and compiles with g++). (BTW: Please don't say "there is an error ...", but give **details**!! Just copy the error message. And perhaps better send your mail (also) to the list so that other people can participate and/or learn from it.) Oliver > > > > >-- Messaggio Originale -- > >Date: Sat, 22 Nov 2003 13:44:42 +0000 > >From: Oliver Kullmann > >To: codaditasso@tiscali.it > >Subject: Re: gcc and template > > > > > >> > > Hello > > I've tried to compile the following program with gcc: > > > > 1 template void > > 2 my_fun1(){ > > 3 my_fun2(); > > 4 }; > > 5 > > 6 template void > > 7 my_fun2(){ > > 8 T prova=1234; > > 9 }; > > 10 > > 11 int ma > >n() > > 12 { > > 13 my_fun1(); > > 14 > > 15 return 0; > > 16 } > > > > but the compiler tell me that there is syntax error before > in line 3. > > Anyway with the c++ builder the program was compiled correctly. What's > the > > problem? Also with t > >e mingw I've obtained the same compile error? > > In the gcc are not possible to call a template function with in another? > > > > > > Greetings from pinzi > > > > Hi, > > at line 3 you are using a non-dependent name ("my_fun2"), and non-dependent > names > >n template definitions are looked up immediately (while dependent > names are looked up at the point of instantiation). > > So you need to declare my_fun2 before the definition of the function template > my_fun1: > > template > void my_fun2(); > > > > 1 template void > > 2 my_fun1(){ > > 3 my_fun2(); > > ... > > Oliver > > Oliver __________________________________________________________________ Tiscali ADSL SENZA CANONE, paghi solo quando navighi! E in pił il modem e' GRATIS! Abbonati subito. http://point.tiscali.it/adsl/index.shtml